gpt4 book ai didi

.net - `x <> Nothing` 与 `x IsNot Nothing`

转载 作者:行者123 更新时间:2023-12-04 18:50:57 25 4
gpt4 key购买 nike

在VB中是否有任何情况x = Nothingx is Nothing 不一样?

另外,x <> Nothing对比 x IsNot Nothing
我认为它们完全相同..但只是想确定一下。

最佳答案

空字符串是有区别的,空字符串只用“=”或“<>”算作Nothing,但对于Is/IsNot不算作Nothing:

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

关于.net - `x <> Nothing` 与 `x IsNot Nothing`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6068008/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com