Doing a comparison simply means comparing the two
signatures. The signature for a delegate is defined by the
function. For each
you can just compare the method signatures:
public delegate int CompareDelegate(string param1, double param2);
public bool IsMatch(MethodInfo methodInfo)
var compare = typeof(CompareDelegate).GetMethod("Invoke");
if (compare.ReturnType != methodInfo.ReturnType)
var methodParams = methodInfo.GetParameters().Select(p => p.ParameterType);
var compareParams = compare.GetParameters().Select(p => p.ParameterType);
That should give you a foundation for checking compatibility, however if you really want to ensure that the method is going to be compatible then you'd also want to compare for things like generic type parameters as well.
Alternatively you can use the
and catch the exception, but doing that for every method is a bad idea.