All rules
IDE0041Language rules (expression-level preferences)

Use 'is null' check

Use 'is null' check

Microsoft docs

Description

This style rule concerns the use of a null check with pattern matching versus the use of the equality operator (==) or calling System.Object.ReferenceEquals(System.Object,System.Object).

Example

// dotnet_style_prefer_is_null_check_over_reference_equality_method = true
if (value is null)
    return;

// dotnet_style_prefer_is_null_check_over_reference_equality_method = false
if (object.ReferenceEquals(value, null))
    return;

// dotnet_style_prefer_is_null_check_over_reference_equality_method = false
if ((object)o == null)
    return;

Configurable options

Vote for the value each option should take in the generated .editorconfig.

dotnet_style_prefer_is_null_check_over_reference_equality_method
default: true
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0