开发者

`x <> Nothing` vs `x IsNot Nothing`

开发者 https://www.devze.com 2023-03-07 17:21 出处:网络
in VB is there any situation whereby x = Nothing is not the same as x is Nothing? Also, 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

精彩评论

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