Single Dimentional Arrays


using System;

// An array stores a fixed-size sequential collection of elements of the same type.

public class SingleDimArray
{
    static void Main(String[] args)
    {
        String[] myArray;                     // declares an array of Strings

        myArray = new String[10];             // allocates memory for 10 Strings
        myArray[0"aa";                    // initialize first element.Array index starts from 0.
        myArray[1"bb";                    // initialize second element
        myArray[2"cc";                    // initialize third element

        Console.WriteLine("Element at index 0 of myArray: " + myArray[0]);
        Console.WriteLine("Element at index 1 of myArray: " + myArray[1]);
        Console.WriteLine("Element at index 2 of myArray: " + myArray[2]);


        //or we can also initialize an array as

        String[] newArray = "dd""ee""ff" };

        Console.WriteLine("Element at index 0 of newArray: " + newArray[0]);
        Console.WriteLine("Element at index 1 of newArray: " + newArray[1]);
        Console.WriteLine("Element at index 2 of newArray: " + newArray[2]);

        Console.ReadLine();

    }

}

Output:
Element at index of myArray: aa
Element at index of myArray: bb
Element at index of myArray: cc
Element at index of newArray: dd
Element at index of newArray: ee
Element at index of newArray: ff