在 VB.net 中,如何从嵌套 class 中的其他函数访问 class 中的函数?
In VB.net, How can I access to a function in a class from an other function in a nested class?
我在 VB.net 开发,但我来自 java,我有想法创建一个匿名的 class 来实现这样的接口:
int h = 4;
Object x = new iInterface({
@Override void f(){
h = 5;
}
});
我不知道该怎么做,所以我想创建一个嵌套的 class 来实现 "iInterface" 但是...
Class N
Dim h = 4
Class n
Implements iInterface
Sub f()
h = 5
End Sub
End Class
End Class
... VisualStudio 在 h 下放了一个毛茸茸的蓝色垫子并对我说:"Reference to a non-shared member requires an object reference"
我该怎么办? >___<
您可能正在寻找共享元素。这是相关文档:https://msdn.microsoft.com/en-us/library/zc2b427x.aspx
否则,您必须显式创建 class 的实例才能
使用它。
像这样:
Class N
Shared h = 4
Class n
Implements iInterface
Sub f()
h = 5
End Sub
End Class
结束Class
我在 VB.net 开发,但我来自 java,我有想法创建一个匿名的 class 来实现这样的接口:
int h = 4;
Object x = new iInterface({
@Override void f(){
h = 5;
}
});
我不知道该怎么做,所以我想创建一个嵌套的 class 来实现 "iInterface" 但是...
Class N
Dim h = 4
Class n
Implements iInterface
Sub f()
h = 5
End Sub
End Class
End Class
... VisualStudio 在 h 下放了一个毛茸茸的蓝色垫子并对我说:"Reference to a non-shared member requires an object reference"
我该怎么办? >___<
您可能正在寻找共享元素。这是相关文档:https://msdn.microsoft.com/en-us/library/zc2b427x.aspx 否则,您必须显式创建 class 的实例才能 使用它。
像这样:
Class N
Shared h = 4
Class n
Implements iInterface
Sub f()
h = 5
End Sub
End Class
结束Class