如何将以下内容转换为Lambda?
Func<int, string> calcState = delegate(int test)
{
return (!MyList.All(i => i > test) ?
(MyList.Any(i => i > test) ? "ein Paar" : "Keiner") : "alle");
};
Run Code Online (Sandbox Code Playgroud)
删除delegate和return关键字.您也不需要指定参数类型 - 它将被推断:
Func<int, string> calcState =
test => (!MyList.All(i => i > test) ? (MyList.Any(i => i > test) ? "ein Paar" : "Keiner") : "alle");
Run Code Online (Sandbox Code Playgroud)
进一步阅读:表达Lambda
| 归档时间: |
|
| 查看次数: |
77 次 |
| 最近记录: |