VB.NET:带有接口的空引用 [英] VB.NET: Null reference with an Interface
本文介绍了VB.NET:带有接口的空引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个空引用警告.伪代码如下:
I have a null reference warning. Dummy code as follows:
Dim poo As IEnumPooTypes
Toilet.GetPooInBowl(poo)
变量 'Poo' 表示它可能导致对象引用未设置错误,但我不能在实例中使用 'New' 关键字.如何让警告消失?
The variable 'Poo' says it may result in an object reference not set error but I cannot use the 'New' keyword with an instance. How do I make the warning go away?
推荐答案
如果 IEnumPooTypes
是一个接口,你就不能实例化一个接口.I
暗示它是一个接口.你需要一个 IEnumPooTypes
的具体实现.
You can't instantiate an interface if IEnumPooTypes
is an interface. The I
is implying that it is an interface. You need a concrete implementation of IEnumPooTypes
.
这篇关于VB.NET:带有接口的空引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文