#122 – Arrays Can Contain Any Type of Object

C# arrays can be declared to contain any type of object, as long as all objects in the array are of the same type.

Here are some examples:

 // Arrays of fundamental types
 int[] numbers = new int[4];
 float[] morenums = { 1.1f, 2.2f };

 // Array of enum   (enum Moods { Cranky, Fearful, Wary };)
 Moods[] hourlyMoods = new Moods[24];

 // Array of object instances
 Person[] family = new Person[7];

Person bob = family[2];    // Reference one element