- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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