Add null checks for all parameters

This refactoring applies to:

  • C#

What: Creates and adds if statements that check nullity of all the nullable, non-checked parameters.

When: You want to quickly add null checks for all applicable method parameters.

Why: Writing null checks for many parameters can be time consuming and repetitive. Using this refactoring is quick and makes the program more robust.


  1. Place your cursor on any parameter within the method.

  2. Press Ctrl+. to trigger the Quick Actions and Refactorings menu.

    Quick actions and refactorings

  3. Select the option to Add null checks for all parameters.

    Add null checks for all

See also