无法将类型“System.Delegate”转换为“T”
private static T CreateDelegate<T>(MethodInfo method)
{
return (T) Delegate.CreateDelegate(typeof(T), method);
}
无法将类型“System.Delegate”转换为“T”
运行不过去,这个怎么转换啊
//
// 摘要:
// 创建指定类型的委托以表示指定的静态方法。
//
// 参数:
// type:
// 要创建的委托的 System.Type。
//
// method:
// 描述委托要表示的静态或实例方法的 System.Reflection.MethodInfo。.NET Framework 1.0 和 1.1 版中仅支持静态方法。
//
// 返回结果:
// 表示指定静态方法的指定类型的委托。
//
// 异常:
// System.ArgumentNullException:
// type 为 null。- 或 - method 为 null。
//
// System.ArgumentException:
// type 不继承 System.MulticastDelegate。- 或 -type 不是 RuntimeType。请参见反射中的运行库类型。-
// 或 - method 不是静态方法,并且 .NET Framework 的版本为 1.0 或 1.1。- 或 - 不能绑定 method。- 或
// -method 不是 RuntimeMethodInfo。请参见反射中的运行库类型。
//
// System.MissingMethodException:
// 未找到 type 的 Invoke 方法。
//
// System.MethodAccessException:
// 调用方无权访问 method。
public static Delegate CreateDelegate(Type type, MethodInfo method);