I have this type that contains two overloads of a generic method. I like to retrieve one of the overloads (with the Func
parameter) using reflection. T
Surprisingly, it looks like you'll need to call GetMethods()
and loop over the methods until you find the one you want.
For example:
var yourMethod = typeof(Foo).GetMethods()
.First(m => m.Name == "Bar"
&& m.GetParameters().Length == 1
&& m.GetParameters()[0].ParameterType.ContainsGenericParameters
&& m.GetParameters()[0].ParameterType.GetGenericTypeDefinition() == typeof(Func<>));