`x <> Nothing` vs `x IsNot Nothing`
in VB is there any situation whereby x = Nothing
is not the same as x is Nothing
?
Also, x <> Nothing
vs x IsNot Nothing
I'm thinking that they are p开发者_运维问答urely identical.. but just wanted to be sure.
There's a difference with empty strings, which do count as Nothing with simply "=" or "<>" but don't count as Nothing for Is / IsNot:
Public Class Test
Public Shared Sub Main()
Dim x As String = ""
Console.WriteLine(x = Nothing) ' True
Console.WriteLine(x Is Nothing) ' False
End Sub
End Class
精彩评论