Differentiate generic methods by type parameters only using reflection?
- by Brian Vallelunga
I'm trying to use reflection to get a specific MethodInfo of a class, but am unsure how to differentiate between the two following methods:
public class Test
{
public IBar<T1> Foo<T1>();
public IBar<T1, T2> Foo<T1, T2>();
}
How can I get a reference to the different Foo methods, assuming I know the number of type parameters? Just calling typeof(Test).GetMethod("Foo") will throw an exception that the method name is ambiguous and there aren't a differing number of parameters to check.