Skip to main content

RCS1221: Use pattern matching instead of combination of 'as' operator and null check

Properties​

PropertyValue
Default SeverityInfo
Minimum language version7.0

Examples​

Example #1​

diagnostic.cs
var y = x as Foo;

if (y == null)
{
return;
}
fix.cs
if (!(x is Foo y))
{
return;
}

Applies to​