I want to create a class using reflection for a generic class.
Could someone tell me how to create it?
I have
public class SomeClass<T>
{
....
}
I need to create a class for SomeClass<T>
using reflection.
Use MakeGenericType method:
Type myParameterizedSomeClass = typeof(SomeClass<>).MakeGenericType(typeof(MyParameter));
ConstructorInfo constr = myParameterizedSomeClass.GetConstructor(typeof(ConstrParamType1),typeof(ConstrParamType2));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With