Just as enumerations group constants together, so arrays can be thought of as grouping variables together. There's a lot of support for arrays built into C#, and we'll take a look at it in Chapter 6. As you know, arrays store data values by index. In C#, arrays are reference types, so you can create a new array with the new operator. You declare an array as type, where type is the data type of each element. For example, here's how to declare an array of five integer elements:
int array1 = new int;
These elements can be addressed with index values 0 to 4, as array1, array1, up to array1. You can see this at work in Listing 1.5, where we've created a C# array, placed data in one of its elements, and displayed that data. ...