有人知道如何动态创建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");
Run Code Online (Sandbox Code Playgroud)
这不编译:
无法将lambda表达式转换为type,
object[]因为它不是委托类型
任何人?
| 归档时间: |
|
| 查看次数: |
1231 次 |
| 最近记录: |