You will need to use reflection:
MethodInfo methodDefinition = GetType().GetMethod("Foo", new Type[] { });
MethodInfo method = methodDefinition.MakeGenericMethod(somethingType);
method.Invoke();
When writing a universal method, it is recommended to use, if possible, universal overload. For example, if the author has Foo<T>()added overloading Foo(Type type), here you will not need to use reflection.
source
share