0

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> {
}
user182917
  • 1,688
  • 2
  • 14
  • 17

0 Answers0