---
title: "Explanation of all LINQ Aggregate functions"  
description: "Here is the explanation of all linq aggregate functions with live examples."  
author: "Ashutosh Patel"  
published: 2025-02-12  
updated: 2025-02-12  
canonical: https://www.mindstick.com/articles/338503/explanation-of-all-linq-aggregate-functions  
category: "linq"  
tags: ["c#", "linq"]  
reading_time: 2 minutes  

---

# Explanation of all LINQ Aggregate functions

In **LINQ** ([Language](https://answers.mindstick.com/qa/43850/how-to-create-digital-clock-in-c-language)-[Integrated](https://www.mindstick.com/forum/33532/handler-pagehandlerfactory-integrated-has-a-bad-module-managedpipelinehandler-in-its-module-list) Query), [aggregate functions](https://www.mindstick.com/forum/158949/what-are-the-conditional-aggregate-functions-in-sql-such-as-sum-case-and-how-are-they-used) such as **SUM**, **MIN**, **MAX**, **COUNT**, **AVERAGE** and **AGGREGATE** help perform calculations on collections. Let's take a look at each with **C# examples**.\
\
**1. SUM()**\
It calculates the total **sum** of numeric [elements](https://yourviews.mindstick.com/story/1372/the-5-elements-of-nature) in a collection.

```cs
List<int> NumberList = new List<int> { 2, 5, 7, 3, 8, 4, 9, 4, 6, };
int sum = NumberList.Sum();
Console.WriteLine("Sum: " + sum); // Output: Sum: 48
```

## 2. MIN()

It returns the **[smallest](https://yourviews.mindstick.com/story/4762/top-10-smallest-mammals-in-the-world)** number in the collection.

```cs
List<int> NumberList = new List<int> { 2, 5, 7, 3, 8, 4, 9, 4, 6, };
int min = NumberList.MIN();
Console.WriteLine("Min: " + min); // Output: Min: 2
```

## 3. MAX()

It returns the **largest** number in the collection.

```cs
int max = NumberList.Max();
Console.WriteLine("Max: " + max); // Output: Max: 9
```

## 4. COUNT()

It returns the **number of elements** in the collection.

```cs
int count = NumberList.Count();
Console.WriteLine("Count: " + count); // Output: Count: 9
```

## 5. AVERAGE()

It computes the **mean (average)** of numeric elements.

```cs
int avg = (int)NumberList.Average();
Console.WriteLine("Average: " + avg); // Output: Average: 5
```

## 6. AGGREGATE()

It performs **[custom](https://www.mindstick.com/interview/33747/buy-the-best-custom-candle-packaging-wholesale-at-icustomboxes) [aggregation](https://www.mindstick.com/forum/217/what-is-aggregation-and-how-it-maps-into-a-java-class)** by applying a [function](https://yourviews.mindstick.com/story/1308/four-types-of-human-teeth-amp-their-function) **cumulatively**.

```cs
int aggValue = NumberList.Aggregate((a, b) => a + b); // ((((2+5)+7)+3)+8)...
Console.WriteLine("Aggregate: " + aggValue); // Output: Aggregate: 48
```

## Complete Example in C#

```cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace MyConsoleApplication
{
   class Program
   {
       List<int> NumberList = new List<int> { 2, 5, 7, 3, 8, 4, 9, 4, 6, };
       static void Main(string[] args)
       {
           Program prog = new Program();
           Console.WriteLine("Sum of Value Is: {0}", prog.SumValue());
           Console.WriteLine("Max Value Is: {0}", prog.MaxValue());
           Console.WriteLine("Min Value Is: {0}", prog.MinValue());
           Console.WriteLine("Average Values Is: {0}", prog.AvgValue());
           Console.WriteLine("Count of Values Is: {0}", prog.CountValue());
           Console.WriteLine("Aggragate of Value is: {0}", prog.AggrateValue());
           Console.WriteLine("Press any key to exit");
           Console.ReadLine();
       }
       public int SumValue()
       {
           int sumNum = NumberList.Sum();
           return sumNum;
       }
       public int MaxValue()
       {
           int maxNum = NumberList.Max();
           return maxNum;
       }
       public int MinValue()
       {
           int minNum = NumberList.Min();
           return minNum;
       }
       public int AvgValue()
       {
           int avgvalue = (int)NumberList.Average();
           return avgvalue;
       }
       public int CountValue()
       {
           int countvalue =  NumberList.Count();
           return countvalue;
       }
       public int AggrateValue()
       {
           int aggValue = NumberList.Aggregate((a, b) => a + b); // ((((2+5)+7)+3)+8)...
           return aggValue;
       }
   }
}
```

I hope you understand clearly. Thanks!

Also, Read: [What is LINQ](https://www.mindstick.com/interview/253/what-is-linq)

---

Original Source: https://www.mindstick.com/articles/338503/explanation-of-all-linq-aggregate-functions

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
