Scenario:
class A { }
class B : A { }
class C<T> where T: A { }
Question
Why cant C<A> = C<B> when B is a subclass of A?
it throws the “cannot implicitly convert” error
Thanks
–UPDATE–
can i create an implicit method for that C<A> would recognize C<B>?
Use co-variant if you need to do this, and because co-variant just work only with interface and delegate, so define an interface with the magic word
outinstead of class:So, you can assign like you want: