Answers for "add items to an array c# with loop"

C#
8

use a for loop to sum an array 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
1

c# append array

List<int> termsList = new List<int>();
for (int runs = 0; runs < 400; runs++)
{
    termsList.Add(value);
}

// You can convert it back to an array if you would like to
int[] terms = termsList.ToArray();
Posted by: Guest on May-05-2020

Code answers related to "add items to an array c# with loop"

C# Answers by Framework

Browse Popular Code Answers by Language