Skip to main content
Source: AL0014PreferPatternMatchingAnalyzer.cs

Description

Pattern matching syntax (is/is not) is more expressive and idiomatic. For null checks, it also bypasses overloaded equality operators.

Bad Code

if (x == null)
if (x != 0)

Good Code

if (x is null)
if (x is not 0)

Properties

  • Category: Style
  • Severity: Info
  • Enabled by default: True
  • Code fix available: True

Configuration

dotnet_diagnostic.AL0014.severity = warning