Showing posts with label Aggregate. Show all posts
Showing posts with label Aggregate. Show all posts

Friday, 17 December 2010

Understanding Aggregate.. well ish anyway

Combine values from list items
var x is of type collection/list/array


var out = x.Aggregate(<seed,>(acc,item) => acc + item);

acc is the accumulator which is returned
item is each item

At position acc + item, a function can exist to provide extra functionallity.

item is never the first item of the array unless you seed from a blank string.

For example:

var out = x.Aggregate("",(acc,item) => acc + item);