有人知道如何动态创建Func<T>
实例吗?
//Create the Func type
Type funcType = typeof(Func<>).MakeGenericType(typeof(string));
//How do I pass a reference to the anonymous method?
Activator.CreateInstance(funcType, () => "test");
代码无法编译:
不能将lambda表达式转换为类型
object[]
,因为它不是委托类型。
有人能解决吗?