link环境下为什么arr.Aggregate(1, (a, b) => a*b)的a来自上一个表达式的值?怎么来的
(a, b) => a*b
这是一个lambda表达式,它是linq反过来调用你的,linq会保存每次迭代的结果,并且自动传过来,不需要你操心
console程序中运行这段代码你就明白了。
int N = 5;
IEnumerable intSequence = Enumerable.Range(1, N);
int agg = intSequence.Aggregate((av, e) => { Console.WriteLine(av + " " + e); return av * e; });
Console.WriteLine("{0}! = {1}", N, agg);