get sum of an array c# code example
Example: sum array c#
//
// Declare two collections of int elements.
//
int[] array1 = { 1, 3, 5, 7 };
List<int> list1 = new List<int>() { 1, 3, 5, 7 };
//
// Use Sum extension on their elements.
int sum1 = array1.Sum();
int sum2 = list1.Sum();