Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Aggregate method in C#
Use the Aggregate method in C# to perform mathematical operations such as Sum, Min, Max, Average, etc.
Let us see an example to multiply array elements using Aggregate method.
Here is our array −
int[] arr = { 10, 15, 20 };
Now, use Aggregate() method −
arr.Aggregate((x, y) => x * y);
Here is the complete code −
Example
using System;
using System.Linq;
using System.IO;
public class Demo {
public static void Main() {
int[] arr = { 10, 15, 20 };
// Multiplication
int res = arr.Aggregate((x, y) => x * y);
Console.WriteLine(res);
}
}
Output
3000
Advertisements
