Friday, January 10, 2020

Do a sum in C# off of a list or an array!

This has this:

int[] array1 = { 1, 3, 5, 7 };
List<int> list1 = new List<int>() { 1, 3, 5, 7 };
int sum1 = array1.Sum();
int sum2 = list1.Sum();

 
 

The last two variables each end up with the number sixteen in them.

No comments:

Post a Comment