Arrays In C Sharp

Here we will examine how Arrays are defined in C Sharp and used.  Array is structure that contains a series of elements of same types( all int, all double etc..).

Examples of array definitions are:

double[] dMyArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};  // a 10 element array.

In C# array index starts at 0 and not at 1.  First element is at index 0 and second element is at index 1.

Arrays are of two types; 
Fixed Length Array and Variable Lengtn Array.  Example above is fixed length array.

How to use variable Length Array?

The format for declaring a variable-sized array is as follows:
double [] dMyArray = new double [N];

dMyArray.Length contains the number of elements in the array.