gil*_*lyb 5 .net c# reflection methodinfo
我有MethodInfo一个关于类类型的方法,该方法是该类实现的接口定义的一部分。
如何MethodInfo在类实现的接口类型上检索方法的匹配对象?
我想我找到了最好的方法来做到这一点:
var methodParameterTypes = classMethod.GetParameters().Select(p => p.ParameterType).ToArray();
MethodInfo interfaceMethodInfo = interfaceType.GetMethod(classMethod.Name, methodParameterTypes);
Run Code Online (Sandbox Code Playgroud)