Answers for "linq sum"

C#
3

sum in c#

int[] arr = new int[] { 1, 2, 3 };
int sum = 0;
for (int i = 0; i < arr.Length; i++)
{
    sum += arr[i];
}

int[] arr = { 3, 6, 4, 1, 6, 8 };

// returns 1
Array.IndexOf(arr, 6);

int maxValue = anArray.Max();
int maxIndex = anArray.ToList().IndexOf(maxValue);
Posted by: Guest on July-19-2020
0

linq sum

int[] numbers = new int[] { 10, 30, 50, 40, 60, 20, 70, 90, 80, 100 };
int total = (from num in numbers select num).Sum();
Posted by: Guest on July-11-2021

C# Answers by Framework

Browse Popular Code Answers by Language