I Have two functions:
- public void DeleteRecord(int id);
- public T DeleteRecord<T>(int id);
Here's how i try to dynamically invoke the generic method:
MethodInfo method = typeof(DAL).GetMethod("DeleteRecord", new[] { typeof(int) });
MethodInfo generic = method.MakeGenericMethod(returnType);
object o = generic.Invoke(null, new object[] { dbname, spname, expandoAsDictionary });
The first line throws an exception because it finds an ambiguous definition. Is there a way i can get the MethodInfo of the generic method without using GetMethods and looping through the results asking for IsGenericMethod?
Edit: Please remove the 'Duplicate' because both of the suggested answers either solve this with an inner loop (GetMethods().Select...) or don't even address overloads.
 
    