Sum in Linq

Gopesh9
Posted by Gopesh9 under LINQ category on | Points: 40 | Views : 1077
A simple example showing how you can sum all the numbers in the array.

int[] numbers = { 6, 2, 1, 1, 9, 8, 2, 7, 2, 0 }; 
int sum = numbers.Sum();
Console.WriteLine("The sum of all numbers in the list is ", sum);

Comments or Responses

Login to post response