I need to call a static method (of a helper class) which has a generic type constraint like this:
public static ResultType SomeMethod<T>(string someParm)
where T : SomeBaseClass
How can I call this method if I only know T by its name (string)?
I have seen this, but I could not figure out how to use MethodBase.Invoke in my case.
UPDATE
After this was flagged as duplicate, I realised I should have asked if the static method is an async method with optional parameters.
public async static Task<ResultType> SomeMethod<T>(string someParm,
string optionalParm) where T : SomeBaseClass
Then I found this answer: .NET invoke an async method. Basically, invoking an async method would return what you expect it to return, which is generally either a Task or Task<>. Bleeding obvious now, LOL
Then, I was getting Parameter mismatch count. It turned out I had to provide all parameters, and specify Type.Missing for optional parameters where I want the method to use the default value.