Is it possible to create a instance of generic class whose type is derived dynamically.
Class GenericClass<T> {
}
Main()
{
string inputtype = "classname, assemblyname";
Type type = Type.GetType(inputtype);
dynamic instance = Activator.CreateInstance(type);
// Want to create a object of GenericClass<T> but I get compiletime errors.
// Is it possible to do like below?
GenericClass<instance> = new GenericClass<instance>();
}
Aucun commentaire:
Enregistrer un commentaire