I'd like to create a list of types, each of which must implement a particular interface. Like:
interface IBase { }
interface IDerived1 : IBase { }
interface IDerived2 : IBase { }
class HasATypeList
{
List<typeof(IBase)> items;
HasATypeList()
{
items.Add(typeof(IDerived1));
}
}
So I know I can do
List<Type> items;
But that won't limit the allowable types in the list to ones that implement IBase. Do I have to write my own list class? Not that it's a big deal, but if I don't have to...