利用该:访问隐藏的共享/静态变量
class outer
public shared X as string = ""
class inner
public shared sub test()
Dim s as string
s = X ' refers to the shared (static) variable in outer
end sub
end class
end class
在试验方法的参考X是在外部类中声明的共享变量,但是,如果我的内部类由该名称所声明的变量(将外部类中的共享变量切掉),我如何才能访问它?
class outer
public shared X as string = ""
class inner
public X as string = "x"
public shared sub test()
Dim s as string
s = X ' this fails because it's an attempt to access an instance variable
end sub
end class
end class
内部类具有比其访问私处没有特殊关系外,其他。它将需要对外部对象的引用。 – 2013-05-04 00:09:41