Assign value to array - CSharp Language Basics

CSharp examples for Language Basics:Array

Description

Assign value to array

Demo Code

using System;/*from w  ww .j av a  2s . com*/
class Program
{
   static void Main(string[] args)
   {
      // declaring the size of the array
      string[] names = new string[4];
      names[0] = "A";
      names[1] = "B";
      names[2] = "C";
      names[3] = "D";
      for (int i = 0; i < names.Length; i++)
      {
         Console.WriteLine(names[i]); // read the item at this index
      }
   }
}

Result


Related Tutorials