我是vb.net新手,在vb.net中做工作流,我需要检查字典是否为空。我声明了一个字典,但没有给它赋值。
当我使用IsNothing()方法时,它给出了对象引用异常。我该怎么检查呢?
Dim CustDicAs New Dictionary(Of String, Integer)
CustDic.IsNothing()发布于 2013-11-11 17:53:35
您可以使用Not Is Nothing或IsNot Nothing或通过Visual Basic中的旧IsNothing函数来检查Nothing的变量。
Dim dict As Dictionary(Of String, String)If Not dict Is Nothing Then‘not nothing End If
If dict End Nothing Then‘not nothing End If
If Not IsNothing(dict) Then‘not nothing End If
我不会再在.NET中使用VB6函数IsNothing,因为它引入了不需要的依赖关系,并且出于前面提到的here的原因(它允许值类型,并且总是返回False)。
https://stackoverflow.com/questions/19903210
复制相似问题