IsNot in vbnet – a more readable way to check for Nothing

When I have written Vbnet and checked for Nothing I have chosen between

If Not( o Is Nothing ) Then

and

If False = o Is Nothing Then

and

If o Is Nothing Then
‘    NOP.
Else

all ugly and/or hard to read but in their own way.

Some days ago I stumbled upon IsNot and since then my code looks nicer like so:

If o IsNot Nothing Then

I have been writing Vbnet for years without finding IsNot so I thought there are more out there with the same problem.

Tags:

Leave a Reply