Nothing当字符串变量没有实例时,它完全引用,而""当字符串变量具有它引用的内容时,它是一个空字符串.
为了区分,您可以提出以下条件:
Dim s As String
If s Is Nothing Then 'It means it is Nothing
End If
If s = "" Then 'It means it points to some instance whose value is empty string
End If
Run Code Online (Sandbox Code Playgroud)
VB.Net也有String.Empty相当于"":
If s = String.Empty Then
End If
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1756 次 |
| 最近记录: |