Suppose I have classes A and B, which derives from A. Suppose I have a method that operates on collections of A's. I'd like to pass it a collection of B's. How can I do that?
In other words:
class A {}
class B : A {}
void doAStuff(List<A> someAs) { // do stuff }
List<B> b = new List<B>();
doAStuff(b); // won't compile
I come to C# from Java, where doAStuff would be coded
void doAStuff(List<? extends A> someAs) { }
and I could pass it a list of B's. Is there a way to do that in C#?