Consider a type like this
public interface IHaveGenericMethod
{
T1 Method<T1>(T1 parm);
T2 Method<T1,T2>(T1 parm);
int Method2(int parm);
}
How do I get 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 the general method, however, I cannot, since parameters are not types per se. So how do I do this? I know I can call
typeof(IHaveGenericMethod).GetMethods()
to get all the methods of this type and then iterate over this collection and perform some match, but it's ugly. Is there a better way?
source
share