I would like to be able to pass the type into a generic method where I only know the name of the type.
I want to do something like the following, but I am getting an error.
var type = typeof(name);
var result = MyGenericMethod<type>();
Is this possible?
Currently I am doing a switch statement, but this is less than ideal as I need to update each time I need to add a new class.
switch (name)
{
case "TypeName1":
result = MyGenericMethod<TypeName1>();
break;
case "TypeName2":
result = MyGenericMethod<TypeName2>();
break;
...
}