8.14 Wrap-Up

This chapter began our introduction to data structures, using arrays to store data in and retrieve data from lists and tables of values. You saw how arrays are declared, created and initialized. We presented examples demonstrating common array manipulations. We introduced C#’s last control statement—the foreach iteration statement—which provides a concise and less error-prone notation for accessing data in arrays and other data structures.

We demonstrated implicitly typed local variables (with keyword var) for which the compiler determines variable types, based on their initializer values. We introduced the exception-handling mechanism and used it to allow a program to continue executing when it attempted to access an array element outside the array’s bounds.

We used arrays to simulate shuffling and dealing playing cards. In that example, we introduced C# 6’s getter-only auto-implemented properties, which define properties that can be used to get, but not set, a value. We also discussed auto-property initialization for auto-implemented properties.

We presented two versions of an instructor GradeBook case study that used arrays to maintain sets of student grades in memory and analyze student grades. Finally, we demonstrate how to define methods that receive variable-length argument lists and how to process command-line arguments passed to Main as a string array.

We continue our coverage of data structures in Chapter 9, where we discuss List, which is a dynamically resizable array-based collection. Chapter 18 discusses searching and sorting algorithms. Chapter 19 introduces dynamic data structures, such as lists, queues, stacks and trees, that can grow and shrink as apps execute. Chapter 20 presents generics, which provide the means to create general models of methods and classes that can be declared once, but used with many different data types. Chapter 21 introduces the data-structure classes provided by the .NET Framework, some of which use generics to allow you to specify the exact types of objects that a particular data structure will store. You should almost always use these predefined data structures instead of building your own. Chapter 21 discusses many data-structures classes that can grow and shrink in response to an app’s changing storage requirements. The .NET Framework also provides class Array, which contains utility methods for array manipulation, such as the Resize method introduced in this chapter. Chapter 21 uses several static methods of class Array to perform such manipulations as sorting and searching the data in an array.

We’ve now introduced the basic concepts of classes, objects, control statements, methods and arrays. In Chapter 9, we introduce Language Integrated Query (LINQ), which enables you to write expressions that can retrieve information from a wide variety of data sources, such as arrays. You’ll see how to search, sort and filter data using LINQ.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset