Calling a method with an instance of derived class of derived generic type
- by madsbirk
Okay, so I have classes
class B<T> : A<T>
class L : K
and a method
void Method(A<K> a) {...}
What I would like to do is this
b = new B<L>();
Method(b); //error
But it is not possible to b to the correct type. Indeed it is not possible to make this cast
A<K> t = new A<L>(); //error
I would really like to not have to change the internals of Method. I have no problems making changes to B and/or L. Do I have any options for making some sort of workaround? I guess it should be possible for Method to execute all of its method calls etc. on b, since B derives from A and L derives from K?