"Not ... Is Nothing" versus "... IsNot Nothing"

nnnn picture nnnn · Sep 20, 2013 · Viewed 89.7k times · Source

Does anyone here use VB.NET and have a strong preference for or against using Not foo Is Nothing as opposed to foo IsNot Nothing? If so, why?

For Example

If var1 IsNot Nothing Then
...
End If

and

If Not var1 Is Nothing Then
...
End If

I just want to know which one is better?
Are they both equally acceptable?

Answer

Paul Michaels picture Paul Michaels · Sep 20, 2013

The

If Not var1 Is Nothing Then

Is a hangover from VB6. There didn't used to be an IsNot, and so this was the only way to determine if a variable was not Nothing. It seems to be redundant in VB.NET.