Why is in the following code an instance of C<B>
not castable to C<A<int>>
, even if B
derives from A<int>
, even with the covariant T
in IC<out T>
?
void Main()
{
var b = new B();
var c = new C<B>();
_ = (C<A<int>>)c;
}
class A<T> {
}
class B : A<int> {
}
interface IC<out T> { }
class C<T> : IC<T> {
}