In VB.NET, what is the difference between
if foo is Nothing Then
doStuff()
End If
and
if foo=Nothing Then
doStuff
Asume:
MyFunc(Foo as object)
Foo - Boxed if ValueType
if foo is Nothing Then
object.ReferenceEquals (Code Inlined - Fastest method)
if foo=Nothing Then
Operators.ConditionalCompareObjectEqual(foo, Nothing, False)
Vb.Net carry this case like Obj1 = Obj2. It do´nt uses Obj.equals(obj2) ! Exception if Obj1 is nothing
This option uses a very complex code as there are a lot options depending all posible foo definitions.
try this:
Sub Main() Dim o As Object = 0 Debug.Print(o Is Nothing) 'False Debug.Print(o = Nothing) 'True End Sub