3
Reply

Can you explain brief about Aggregate() extension method in LINQ?

Pankaj Pathak

Pankaj Pathak

11y
1.7k
0
Reply

    http://www.dotnetperls.com/aggregate

    http://www.dotnetperls.com/aggregate

    The delegate for the Aggregate extension method accepts two integer arguments and returns an integer value representing the sum of both input parameters. The Aggregate extension method loops through each element of the list and performs the operation returned by the delegate passed in. Alternatively, and instead of using lambda expressions, we could have used anonymous methods to write an inline delegate:foreach (List l in lstUserData) {lstSums.Add(l.Aggregate(delegate(int sum, int elmnt) { return sum elmnt;} )); }