Large volumes of data are simpler to organize and work with when using arrays. In C#, an array is a structure in which a fixed-size sequential collection of identical-type elements is stored. Every array in C# is dynamically allocated.
Every array is made up of contiguous memory addresses. The first array element is denoted by the lowest address, while the last array element is denoted by the highest address. The index, which stores values, starts at 0 and should be sequentially increased by 1 until it reaches the array's size.
An array in C# can be declared using the below syntax. E.g.: int [] EmployeeID; int represents datatype -> used to specify the type of elements in the array. [ ] represents the memory size the array can hold. EmployeeID represents an identifier -> which specifies the name of the array.
Array declaration itself does not initialize the array. As array is a reference type, we must create an instance of array using the keyword “new.” EmployeeID = new int [10]; After initialization, we must assign values to the array using index numbers like below. EmployeeID [0] = 2078; EmployeeID [1] = 2167;
There are 3 types of C# arrays: 1. One-dimensional array 2. Multidimensional array 3. Jagged array
You can use object as the array's type if you want it to store elements of any type. All types, both user-defined and predefined, reference types, and value types, descend directly or indirectly from object in the C# unified type system.