Aggregation Operations (C#)

An aggregation operation computes a single value from a collection of values. An example of an aggregation operation is calculating the average daily temperature from a month's worth of daily temperature values.

The following illustration shows the results of two different aggregation operations on a sequence of numbers. The first operation sums the numbers. The second operation returns the maximum value in the sequence.

Illustration that shows LINQ aggregation operations.

The standard query operator methods that perform aggregation operations are listed in the following section.

Methods

Method Name Description C# Query Expression Syntax More Information
Aggregate Performs a custom aggregation operation on the values of a collection. Not applicable. Enumerable.Aggregate

Queryable.Aggregate
Average Calculates the average value of a collection of values. Not applicable. Enumerable.Average

Queryable.Average
Count Counts the elements in a collection, optionally only those elements that satisfy a predicate function. Not applicable. Enumerable.Count

Queryable.Count
LongCount Counts the elements in a large collection, optionally only those elements that satisfy a predicate function. Not applicable. Enumerable.LongCount

Queryable.LongCount
Max Determines the maximum value in a collection. Not applicable. Enumerable.Max

Queryable.Max
Min Determines the minimum value in a collection. Not applicable. Enumerable.Min

Queryable.Min
Sum Calculates the sum of the values in a collection. Not applicable. Enumerable.Sum

Queryable.Sum

See also