How do I call a static method from a Type, assuming I know the value of the Type variable and the name of the static method?
public
Note, that as 10 years have passed. Personally, I would add extension method:
public static TR Method(Type t, string method, object obj = null, params object[] parameters)
=> (TR)t.GetMethod(method)?.Invoke(obj, parameters);
and then i could call it with
var result = typeof(Foo1Class).Method(nameof(Foo1Class.Foo1Method));
- 热议问题