This is a question associated with another question I asked before. I have an overloaded method:
public void Add<T>(SomeType<T> some) { }
public void Add<T>(AnotherType<T> another) { }
How can I find each method by reflection? e.g. How can I get the Add<T>(SomeType<T> some)
method by reflection? Can you help me please? Thanks in advance.
Look into the MethodInfo Members: http://msdn.microsoft.com/en-US/library/system.reflection.methodinfo_members(v=vs.80).aspx
There are helper properties for
IsGenericMethodDefinition
andGetParameters
. Both could help you figure out what function is what.The trick here is describing that you want the parameter to be
SomeType<T>
, whereT
is the generic type of theAdd
method.Other than that, it's just about using standard reflection, like CastroXXL suggested in his answer.
Here's how I did it: