Arrays Properties

The Array class in C# provides various properties and methods to work with arrays.
For example, the Length and Rank properties return the number of elements and the number of dimensions of the array, respectively. You can access them using the dot syntax, just like any class members.

The Code:

New Project170

The Output of Your Program:

New Project171

The Length property can be useful in for loops where you need to specify the number of times the loop should run.

The Code:

New Project172

The Output of Your Program:

New Project173

Array Methods

There are a number of methods available for arrays.
Max returns the largest value.
Min returns the smallest value.
Sum returns the sum of all elements.

The Code:

New Project175

The Output of Your Code:

New Project174

C# also provides a static Array class with additional methods. You will learn about those in the next module.