Arrays in C#
- An array stores a fixed-size sequential collection of elements of the same type.
- An array is a group of like-typed variables that are referred to by a common name.
- All arrays consist of contiguous memory locations.
- In C#, array is an object of base type System.Array.
- In C#, array index starts from 0. We can store only fixed set of elements in C# array.
Declaring a Array:
datatype[] arrayName;
- datatype is used to specify the type of elements in the array.
- [ ] specifies the rank of the array. The rank specifies the size of the array.
- arrayName specifies the name of the array.
Array Initialisation:
int[] array1= new int[5];
No comments