← back to index

S2358 — "IsNot" should be used instead of "Not ... Is ..."

Language: VB.NET  |  Type: CODE_SMELL  |  Severity: Major

Tags: clumsy

Why is this an issue?

The ... IsNot ... syntax is more compact and more readable than the Not ... Is ... syntax.

Noncompliant code example

Module Module1
    Sub Main()
        Dim a = Not "a" Is Nothing ' Noncompliant
    End Sub
End Module

Compliant solution

Module Module1
    Sub Main()
        Dim a = "a" IsNot Nothing  ' Compliant
    End Sub
End Module