I have a generic class that takes two types. But I need to pass them in as variables at runtime.
For example:
Type typeA = typeof(string);
Type typeB = typeof(int);
var myInstance = new myClass<typeA, typeB>();
But this doesn’t seem to work. The compiler complains that typeA is a variable but is used like a type
. The problem is I don’t know the types at compile time. They will be determined by a user selection at runtime.
How can I pass in the type as a Type
variable?