开发者

`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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜