I have a question:
I have a method, who receives a string type as parameter (because its dynamic), how I have a method, this one:
internal static List<T> ToModel<T>(this DataTable dt)
var myClassAsString = "Sponsors";
well, the problem is how to initialize the method `ToModel`
Type ctype = Type.GetType("myClassAsString ");
var internalType = Activator.CreateInstance(ctype).GetType();
prop.SetValue(ToModel<internalType>(dataset.Tables[1]), null);
But, I get this error:
internalType is used as Type, but is a variable.
How I can assign the dynamic value to <T>
Aucun commentaire:
Enregistrer un commentaire