Search⌘ K

Aggregate Method

Explore how to use the Aggregate method in LINQ to perform operations that combine collection elements into one accumulated result. Understand how to implement seeding and aggregation functions, track accumulation across iterations, and apply it to real-world examples like finding maximum values.

How to perform an operation carrying the result

The Aggregate method applies a function to a collection, carrying the result to the next element. It aggregates the result of a function. The Aggregate method takes two parameters: a seed and an aggregating function that takes the accumulated value and one element from the collection.

On the first iteration, the Aggregate method executes the aggregating function using the seed and the first element of the collection as ...