在C#代码中,如何检查给定方法是否可以由特定委托类型表示?
@H_502_2@我首先根据我的类型知识尝试了一些东西:
// The delegate to test against. void TargetDelegate(string msg); // and... var methodInfo = Type.GetMethod(..); // obtain the MethodInfo instance. // try to test it typeof(TargetDelegate).IsAssignableFrom(methodInfo.GetType());@H_502_2@但这只涉及类型而不是方法 – 它总是错误的. @H_502_2@我倾向于相信答案在于
Delegate
Type,但我现在只是在FCL四处游荡.任何帮助,将不胜感激.