标签:
https://msdn.microsoft.com/en-us/library/bb549218(v=vs.110).aspx
public static TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func);
An IEnumerable<T> to aggregate over.
The initial accumulator value.
An accumulator function to be invoked on each element.
举例:
https://www.codewars.com/kata/beginner-reduce-but-grow/train/csharp
对数组中的元素,计算累乘
using System.Linq; public class Kata { public static int Grow(int[] x) { return x.Aggregate(1, (current, item) => current * item); } }
标签:
原文地址:http://www.cnblogs.com/chucklu/p/5951708.html