The type C
is defined as:
public class C : A<long>.B { }
The type A
is defined as:
class A<T> {
public class B : A<long> {
public void f() {
Console.WriteLine( typeof(T).ToString());
}
public class C : A<long>.B { }
}
}
So if you create a new C
then the type parameter for A
is long
.
In the statement var c = new A<float>.B.C();
, A<float>
and B
are just parts of the "path" to the nested class C
. The fact that A<float>
is part of that path does not change the fact that C
is an A<long>.B
.
The float
parameter and the fact that B
is an A<long>
are not relevant to determine the type of T
inside c.f()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…