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 −
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); } }
3000