class A
{
public static void M<T>() { ... }
}
...
Type type = GetSomeType();
Then I need to call A.M<T>()
where type == typeof(T)
.
Reflection?
Yes, you need reflection. For example:
var method = typeof(A).GetMethod("M");
var generic = method.MakeGenericMethod(type);
generic.Invoke(null, null);
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