How to create an array in c#?

How to create an array in c#?

 

In this article, you will learn how to create an array in c#, to declare an array, 
Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. Define the variable type with square brackets.

 

string[] ch = {"A", "B", "C", "D"};

 

Example:

using System;

namespace usingcsharp
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] cars = {"A", "B", "C", "D"};
      Console.WriteLine(cars[1]);
    }
  }
}

Output

 

B

2021-10-03