How to work with arrays in c#?

Arrays are used to store multiple values in a single variable.

Example:


  int[] numbers = new int[3] {1, 2, 3};
  Console.WriteLine(numbers[0]);  // Output: 1
  

Solution:

Use loops and other methods to manipulate arrays:


  for (int i = 0; i < numbers.Length; i++)
  {
      Console.WriteLine(numbers[i]);
  }
  

Beginner's Guide to C#