Introduction
This chapter introduces the important topic of data structurescollections of related data items. Arrays are data structures consisting of related data items of the same type. Arrays are fixed-length entitiesthey remain the same length once they are created, although an array variable may be reassigned such that it refers to a new array of a different length.
After discussing how arrays are declared, created and initialized, we present a series of examples that demonstrate several common array manipulations. We also present a case study that uses arrays to simulate shuffling and dealing playing cards for use in card game applications. The chapter demonstrates C#'s last structured control statementthe foreach repetition statementwhich provides a concise notation for accessing the data in arrays (and other data structures as you will see in Chapter 27, Collections). Two sections of the chapter enhance the GradeBook case study from Chapters 46. In particular, we use arrays to enable the class to maintain a set of grades in memory and analyze student grades from multiple exams. These and other examples demonstrate the ways in which arrays allow you to organize and manipulate data.