【发布时间】:2013-02-09 01:29:00
【问题描述】:
来自LINQ QuizQ4和Q5的问答
将colors数组定义为:
string[] colors = { "green", "brown", "blue", "red" };
并从 Q4 的答案中查询:
var query =
from c in colors
where c.Length == colors.Max (c2 => c2.Length)
select c;
我是否正确理解外部查询迭代表达式 c2.Length 将被评估 16 次?
也就是说,对于colors 数组中的每个项目с,colors.Max (c2 => c2.Length) 将被评估一次,即Max() 计算将总共进行 4 次。对于每个Max() 评估,c2.Length 将被找到 4 次?
【问题讨论】:
标签: c# linq collections lambda max