有了这个:
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