不明确的类型名称

And*_*eas 1 c# types

我对类型的阴影可见性存在问题.我们假设以下代码:

namespace A {
    class B {
        int V1;
        class A {
            class B { }
            void Foo() {
                A.B b; 
                // "b" should be of the first type "B", 
                // but it actually points to A.B.A.B
                b.V1 = 1; //Compile error
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如何在声明"b"的地方声明类型"AB"的变量(其中"A"应该是命名空间,而不是嵌套的类"A")?

Pat*_*gne 11

使用"全局"关键字:

global::A.B b;