samedi 24 août 2019

Using a class name string as a generic type parameter

I have an Unpack() function that takes a generic parameter T where T is a class i.e.

var test = Unpack<ExampleClass>();

The above example works fine, but I am in a situation where I need to do the same as above, but I only know the class/generic parameter name in a string. In other words, how can I do the same thing as above with:

string className = "ExampleClass";

instead of the class ExampleClass?





Aucun commentaire:

Enregistrer un commentaire