I have:
– an interface : IMyType
– some classes implementing it : MyType1 , MyType2 , MyType3
How can I define a list of type IMyType?
var myList = new List<Type> {typeof (MyType1), typeof (MyType2)};
The above list does not force types to be IMyType type, and I can add any type to the list
If you want determine what’s implementation class, you can use obj.GetType() or operator obj is MyType1