Array
To Create and sort array
To create and sort array
Arrays are declared using parentheses (in Visual Basic) or square braces (in C#) as
part of a variable declaration. As with the String type, System.Array provides members
for working with its contained data. The following code declares an array with some
initial data and then sorts the array:
' VB
' Declare and initialize an array.
Dim ar() As Integer = { 3, 1, 2 }
' Call a shared/static array method.
Array.Sort(ar)
' Display the result.
Console.WriteLine("{0}, {1}, {2}", ar(0), ar(1), ar(2))
// C#
// Declare and initialize an array.
int[] ar = { 3, 1, 2 };
// Call a shared/static array method.
Array.Sort(ar);
// Display the result.
Console.WriteLine("{0}, {1}, {2}", ar[0], ar[1], ar[2]);
In C# there are 3 types of array single dimensional, multidimensional and jagged array.
//Declaration of multiple dimensional array
int[ , ] arr = new int[2,3];
//initialization
int[ , ] arr = new int[2,3]{{1,2,3},{4,6,5}};
Jagged array means array of array.
//Declaration of Jagged array
int[][] arr = new int[2][];
It must be initialized procedurally