I\'m trying to pass A list of DerivedClass to a function that takes a list of BaseClass, but I get the error:
DerivedClass
BaseClass
cannot convert from
It is because List is in-variant, not co-variant, so you should change to IEnumerable which supports co-variant, it should work:
List
in-variant
co-variant
IEnumerable
IEnumerable bcl = new List(); public void doSomething(IEnumerable bc) { // do something with bc }
Information about co-variant in generic