根据调试器,我有一个名为myCancelled
Newtonsoft.Json.Linq.Jtoken 类型的变量,其值为 Nothing。我还将它转换为 Object 并且所有这些条件都失败了。我的问题很简单:如何检查它是否为 Nothing/Null/False/Empty?
这是我尝试过的。这些条件都不为真:
If myCancelled Is Nothing Then
'Doesn't come here
End If
If myCancelled = DBNull.Value.ToString Then
'Doesn't come here
End If
If myCancelled = "null" Then
'Doesn't come here
End If
If IsDBNull(myCancelled) Then
'Doesn't come here
End If
If myCancelled Is DBNull.Value Then
'Doesn't come here
End If
If String.IsNullOrEmpty(myCancelled) = True Then
'Doesn't come here
End If
If myCancelled.ToString = "Nothing" Then
'Runtime error
End If
If myCancelled = DBNull.Value Then
'Runtime error
End If
If IsNothing(myCancelled) Then
'Doesn't come here
End If
我是 VB.net 的新手,因此不胜感激。
编辑
这个有效,但它让误报通过(当 myCancelled 有它的值时,条件为真)
If Not myCancelled Then
' It comes here
End If