如下Expression<Fun<myentity,int>> zz=GetLambda();如何取得其中函數返回的int值?
1 回答

POPMUISE
TA貢獻1765條經驗 獲得超5個贊
using System;
using System.Linq.Expressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//表達式創建
Expression<Func<int, int>> zz = m => m + 1;
//將表達式編譯
Func<int, int> foo = zz.Compile();
//獲取返回結果
int result = foo(9);
Console.WriteLine(result.ToString()); //output: 10
Console.ReadKey();
}
}
}
- 1 回答
- 0 關注
- 528 瀏覽
添加回答
舉報
0/150
提交
取消