ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code Syntax Style: Null checking pattern

Last modified: 08 April 2024

When checking an expression for null with the type-testing 'is' operator, you can choose between two null-checking patterns:

  • Use the 'not null' pattern that makes the expression more readable.

  • Use the object pattern syntax `{ }` that makes the expression more flexible, allowing you to declare a local variable after it.

ReSharper helps you enforce style preferences for null-checking patterns in the existing code and takes your preferences into account when it produces new code with code completion and code generation features, applies code templates and performs refactorings.