skip to main
|
skip to sidebar
Arrays
- Array is a collection of elements stored in a contiguous block of memory locations.
- Arrays are a collection of similar data types.
- Arrays shares same name with different index numbers starting from zero(0).
- Arrays are reference type, hence they stored in heap memory.
- Some of the Array methods.s
- Array.Length() //returns no of elements
- Array.GetLength(0) //returns no of rows
- Array.GetLength(1) //returns no of columns (for multi-dimentional arrays)
- Array.Sort() //returns ascending order
- Array.Reverse() //returns in reverse order
- Arrays are three types. They are…
One Dimensional arrays:
E.g.: int [] x= new int [] {1, 2, 3};
Multi Dimensional arrays:
Arranging a set of elements in rows & columns is called multi dimensional array.
E.g.: int [,] x= new int [2,2];
Jagged arrays:
Jagged array is a collection of number of rows which may contain discrete number of the elements in each row. It is also called as Dynamic array or Array of array.
E.g.: int [][] x= new int [2][];
x[0]=new int [] {1, 2, 3};
x[1]=new int [] {4,5}
0 comments :
Post a Comment