Chapter 7: Stepping through Collections
In This Chapter
Handling a directory as a collection of files and a file as a collection of bytes
“Enumerating,” or iterating, a collection
Implementing an indexer for easy access to collection objects
Easily looping through a collection with the C# iterator blocks
Chapter 6 in this minibook explores the collection classes provided by the .NET Framework class library for use with C# and other .NET languages. Collection classes are constructs in .NET that can be instantiated to hold groups of items (see Chapter 6).
The first part of this chapter extends the notion of collections a bit. For instance, consider the following collections: a file as a collection of lines or records of data, and a directory as a collection of files. Thus, this chapter builds on both the collection material in Chapter 6 of this minibook and the file material in Book III.
However, the focus in this chapter is on several ways to step through, or iterate, all sorts of collections, from file directories to arrays and lists of all sorts.
Iterating through a Directory ...