linq Sum
linq Sum
public static void Sum() { // Sum - Simple int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; double numSum = numbers.Sum(); Console.WriteLine("The sum of the numbers is {0}.", numSum); // Sum - Projection string[] words = { "cherry", "apple", "blueberry" }; double totalChars = words.Sum(w => w.Length); Console.WriteLine("There are a total of {0} characters in these words.", totalChars); }
Output
linq Sum
Reviewed by Bhaumik Patel
on
6:35 PM
Rating: