在VB.net中,如何从嵌套类中的其他函数访问类中的函数? [英] In VB.net, How can I access to a function in a class from an other function in a nested class?

查看:483
本文介绍了在VB.net中,如何从嵌套类中的其他函数访问类中的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发VB.net,但我来自java,我有想法创建一个实现这样的接口的匿名类:

I'm developing in VB.net but I'm come from java and I have the idea to create a anonymous class who implements an interface like this:

int h = 4;

Object x = new iInterface({
    @Override void f(){
        h = 5;
    }
});

我不知道怎么做,所以我想创建一个嵌套的类来实现iInterface但是......

I didn't know how to do it, so I think to create a nested class who implments the "iInterface" but...

Class N
    Dim h = 4
    Class n
        Implements iInterface
        Sub f()
            h = 5
        End Sub
    End Class
End Class

... VisualStudio在h下放置一个蓬松的蓝色垫子并对我说:对非共享成员的引用需要对象引用

... VisualStudio puts a fluffy blue mat under h and says to me: "Reference to a non-shared member requires an object reference"

我该怎么办? > ___<

What should I do? >___<

推荐答案

这样的事情:

Class N
Shared h = 4
Class n
    Implements iInterface
    Sub f()
        h = 5
    End Sub
End Class

结束等级

这篇关于在VB.net中,如何从嵌套类中的其他函数访问类中的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆