This question already has an answer here:
I have a class with two methods, overloaded with identical name and arguments, but one is generic:
public class Foo
{
public string Bar(string s) { throw new NotImplementedException(); }
public T Bar<T>(string s) { throw new NotImplementedException(); }
}
How can I get the MethodInfo
for one of these methods? e.g:
var fooType = typeof(Foo);
var methodInfo = fooType.GetMethod("Bar", new[] { typeof(string) }); // <-- [System.Reflection.AmbiguousMatchException: Ambiguous match found.]
Aucun commentaire:
Enregistrer un commentaire