Skip to main content

RCS1199: Unnecessary null check

Properties​

PropertyValue
Default SeverityInfo
Minimum language version-

Examples​

Example #1​

diagnostic.cs
bool? x = null;

// ...

if (x.HasValue && x.Value)
{
}
fix.cs
if (x == true)
{
}

Example #2​

diagnostic.cs
bool? x = null;
bool y = false;

// ...

if (x != null && x.Value == y)
{
}
fix.cs
if (x == y)
{
}

Applies to​