Reputation: 2075
I have an issue with the shadowed visibility of types. Let's assume the following code:
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
}
}
}
}
How can I declare a variable of Type "A.B" (where "A" should be the namespace, not the nested class "A") at the place, where "b" is declared?
Upvotes: 1
Views: 472
Reputation: 6684
You can use an alias:
using ClassB = A.B;
Now ClassB
refers to the type you want.
However, I would very strongly urge you to reconsider your class names so this is no longer a problem.
Upvotes: 4