C#

C#

Made by DeepSource

Unary is expression can be simplified CS-R1094

Anti-pattern
Critical
Autofix

The is operator allows you to check if a variable belongs to a specific type. The same operator can be chained with not to check for the inverse. It is therefore recommended that you simplify the is expression to improve readability.

Bad Practice

if (!(foo is Foo))
{
    // ...
}

Recommended

if (foo is not Foo)
{
    // ...
}

Reference