C# Arrays

An array is a group of contiguous data items that share a common name. Arrays can be of any variable type. In C#, There are three types of Array:

  • 1. One-Dimensional Array
  • 2. Two-Dimensional Array
  • 3. Variable-Size Array

One-Dimensional Array: A list of items can be given one variable name with only one subscript and such a variable is called a One-Dimensional Array. In Mathematics, we often deal with variables that are single subscripted. For instance, we use this equation:
C# Arrays
tocalculatee the average of n value of x. The subscripted variable xi refers to the ith element of x. In C#, a single-subscripted variable xi can be expressed as:

x[0], x[1], x[2],....., x[n]

The subscript begins with the number 0 and that is:
x[0] is allowed.

int[] num=new int[4];

The value of the array elements can be assigned as follows:

Two-Dimensional Array: Two-Dimensional Array are stored in memory shown below:
C# Two-Dimensional-Array
For creating Two-Dimensional Arrays, we must follow the same steps as that of simple arrays, we may create a Two-Dimensional Array-like this:

int[,] num;
num=new int[2,4];


int[,] num=new int [2,4];