Free mag vol1 | Page 201

CHAPTER 4  CORE C# PROGRAMMING CONSTRUCTS, PART II Here, as you are iterating over the contents of myObjects, you print out the underlying type of each item using the GetType() method of System.Object, as well as the value of the current item. Without going into too much detail regarding System.Object.GetType() at this point in the text, simply understand that this method can be used to obtain the fully qualified name of the item (Chapter 15 examines the topic of type information and reflection services in detail). The following output shows the result of calling ArrayOfObjects(). => Array of Objects. Type: System.Int32, Value: 10 Type: System.Boolean, Value: False Type: System.DateTime, Value: 3/24/1969 12:00:00 AM Type: System.String, Value: Form & Void Working with Multidimensional Arrays In addition to the single-dimension arrays you have seen thus far, C# also supports two varieties of multidimensional arrays. The first of these is termed a rectangular array, which is simply an array of multiple dimensions, where each row is of the same length. To declare and fill a multidimensional rectangular array, proceed as follows: static void RectMultidimensionalArray() { Console.WriteLine("=> Rectangular multidimensional array."); // A rectangular MD array. int[,] myMatrix; myMatrix = new int[6,6]; // Populate (6 * 6) array. for(int i = 0; i < 6; i++) for(int j = 0; j < 6; j++) myMatrix[i, j] = i * j; } // Print (6 * 6) array. for(int i = 0; i < 6; i++) { for(int j = 0; j < 6; j++) Console.Write(myMatrix[i, j] + "\t"); Console.WriteLine(); } Console.WriteLine(); The second type of multidimensional array is termed a jagged array. As the name implies, jagged arrays contain some number of inner arrays, each of which may have a different upper limit. For example: static void JaggedMultidimensio