【发布时间】:2018-01-17 13:12:16
【问题描述】:
我正在尝试使用为 double.CompareTo 创建一个函数。
我是这样创建的:
var method = typeof(double).GetMethod("CompareTo", new Type[] { typeof(double) });
var func = (Func<double, double, int>)Delegate.CreateDelegate(typeof(Func<double, double, int>), method);
这样的 string.CompareTo 可以正常工作:
var method = typeof(string).GetMethod("CompareTo", new Type[] { typeof(string) });
var func = (Func<string, string, int>)Delegate.CreateDelegate(typeof(Func<string, string, int>), method);
我得到一个参数异常说“目标方法不能被绑定,因为它的签名或安全透明度与委托类型不兼容”(从瑞典语免费翻译)
怎么了?
【问题讨论】: