Array and Types of Array
Write short notes on array and different types of array.
An array is a group or collection of similar type of elements. An array is a group or collection of similar values. An array contains a number of variables, which are accessed through computed indexes. The various value contained in an array are also called the elements of array. All elements of an array have to be of same type, and this type is called the element type of the array. The element of an array can be of any type including an array type.
An array has a rank that determines the number of indexes associated with each array elements. The rank of an array is also referred as the dimension of the array. An array may be:
An array with a rank of one is called single-dimensional array, and an array with a rank greater than one is called a multi dimensional array.
Each dimension of array has an associated length, which is an integer number greater than or equal to zero. For a dimension of length n, indices can range from 0 to n-l. In C#, array types are categorized under the reference types derived from. the abstract base. Types system. Array.
Single Dimensional Array
Single-dimensional arrays have a single dimension (ie. are of rank 1). The process of creation of arrays is basically divided into three steps:
1. Declaration of Array
2. Memory Allocation for Array
3. Initialization of Array
Declaration of Array
To declare an array in C# place a pair of square brackets after the variable type. The syntax is given below :
int [ ] a;
int [ ] m, n ;