C#

C#

By DeepSource

Unary is expression can be simplified CS-R1094

Anti-pattern

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.

Examples

Bad Practice

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

Recommended

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

Reference