Linq Example 42 - Aggregate

11:38 PM
Linq Query:

//Aggregate

            double[] doubles = { 1.7, 2.3, 1.9, 4.1, 2.9 };
            double product = doubles.Aggregate((CurrentValue, NextValue) => CurrentValue  * NextValue);            

            Console.WriteLine("Total product of all numbers: {0}", product);

//

Output:
Total product of all numbers: 88.33081

0 comments:

Post a Comment