I have a reflected Type, which ends up being a List<Type>
. So I have:
Type modelType = GetMyType();
So - modelType
could be List<ClassA>
or List<ClassB>
, etc. depending on the situation.
How do I create this type, and then populate it?
I know I can do this:
var myList = Activator.CreateInstance(modelType);
But then how do I add items to it, which I would normally do with myList.Add(new ClassA())
or myList.Add(new ClassB())
knowing that I don't really know the ClassA
or ClassB
type - I just know that modelType is List<ClassA>
Aucun commentaire:
Enregistrer un commentaire