Let's say I have a generic method (retrieved from parent type with reflection):
void MyType::MyMethod<T>(T[], int, int)
I want to know if I can invoke that method on some type list:
byte[], int32, int32
Obviously the answer is yes.
However I'd like to find a generic way to find the best overload (among several generics) matching a parameter list.
I can easily get all methods:
MyType.GetMethods().Where(m => m.Name == "MyMethod")
then filter to match parameter count:
.Where(m => m.GetParameters().Count() == 3)
but then I'm blocked.
Aucun commentaire:
Enregistrer un commentaire