Checking for nothing

  • Thread starter Thread starter John
  • Start date Start date
If myVariable Is Nothing Then

End If

If myVariable IsNot Nothing Then

End If

If Not myVariable Is Nothing Then

End If
 
If foo is a reference type:
"If foo Is Nothing Then"

If foo is a value type:
"If foo = Nothing Then"
Note that for value types, the check for equality with Nothing just checks
whether the value is the default value for the value type.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
 
Back
Top