Answers for "C# program to find sum of array elements"

C#
3

c# sum of array elements#

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

C# program to find sum of array elements

,2,3,4,5,6
Posted by: Guest on September-14-2021
0

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();
Posted by: Guest on September-28-2020

Code answers related to "C# program to find sum of array elements"

C# Answers by Framework

Browse Popular Code Answers by Language