class B : A {}
class Sub<T> where T:A
{
//...
}

I want to store Sub instances in a collection.

var c = new List<Sub<A>>();
c.Add(new Sub<B>()); //doesn't work

However, to get it to actually work, I have to declare an interface and store instances of that interface.

interface IBase
{
    void DoStuff(A a);
}

var c = new List<IBase>();
c.Add(new Sub<B>()); //works

Is there a more elegant way of doing this?

Edit
Report