Almost all of the examples in previous chapters have dealt with one object at a time. In many applications, however, you want to work with a collection of objects all at the same time. The simplest collection in C# is the array, and it's the only collection type for which C# provides built-in support. The other collection types, such as stack and queue, are not part of the language; they are part of the Framework Class Library, and we'll cover those in detail in Chapter 14. The cool thing about arrays is that you can pass them around as though they were a single object, yet they contain several objects of the same type. Arrays really come into their own in combination with loops, which you learned about back in Chapter 5. In this chapter, you will learn to work with three types of arrays: one-dimensional arrays, multidimensional rectangular arrays, and jagged arrays.
An array is a collection of objects, all of the same type (all
ints, all strings, and so on). Arrays are also indexed, meaning that the language provides a way for you to say "Get me the third item in the array." Indexing also means that the items in the array are stored in a specific order, which further means that you can loop through the contents of the array in order. That process is called iteration, and we'll show you how to do it in a minute. Arrays are a standard feature of almost all modern languages, and C# provides built-in syntax for declaring and using arrays.
Arrays are a bit ...