Consider type like this one
public interface IHaveGenericMethod { T1 Method<T1>(T1 parm); T2 Method<T1,T2>(T1 parm); int Method2(int parm); }
How do I get a methodInfo for its methods? for a regular non-generic method, like method2, I can go with
typeof(IHaveGenericMethod).GetMethod('methodName',new Type[]{typeof(itsParameters)});
for a generic method though, I can’t, since it’s parameters are not types per-se. So, how do I do that? I know that I can call
typeof(IHaveGenericMethod).GetMethods()
to get all methods of that type, and then iterate over that collection and do some matching, but it’s ugly. Is there a better way?
Well, they are types – of sorts:
So you can check by the number of args, and check the signature. But nothing cleaner.