.NET C# Arrays


An array is a variable that can store more than one value of same data type. 
A normal variable can store only one value and when you want to store more than one value in a variable then declare that variable as an array.

In C# array element index starts with zero and ends with size -1 same as in case of an array in C.

One Dimensional Arrays in C#



Syntax : DataType[] ArrayName = new DataType[Size];

Example

  int[] digits = new int[10];

            String[] names = new string[10];

            object[] objects = new Object[10];



In C#, Array can be declared and initialized at a time as below

 //Int Array

            int[] digits = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

            //String Array

            string[] names = { "John", "Bill", "Harry" };

            //Char Array

            char[] chararray = { 'a', 'b', 'c', 'd', 'e', 'f' };






Arrays in .net, C# Array, .net arrays, One Dimensional Arrays in C#.NET