Chapter 23: Collections, Enumerators, and Iterators


Highlights

This chapter discusses one of the most important parts of the C# library: Collections. In C#, a collection is a group of objects. The .NET Framework contains a large number of interfaces and classes that define and implement various types of collections. Collections simplify many programming tasks because they offer off-the-shelf solutions to several common, but sometimes tedious-to-develop, data structures. For example, there are built-in collections that support dynamic arrays, linked lists, stacks, queues, and hash tables. Collections are a state-of-the-art technology that merits close attention by all C# programmers.

The release of C# 2.0 caused a major change to collections because it added generic collections. This resulted in the addition of many new generic classes and interfaces, and two completely new namespaces. The inclusion of the generic collections essentially doubled the number of collection classes and interfaces. Thus, the Collections API is now quite large. Although the generic and non-generic collections work in similar ways, there are some differences. Both generic and non-generic collections are described in this chapter.

Also described in this chapter are two features that relate to collections: enumerators and iterators. Iterators are another C# 2.0 innovation. Both enumerators and iterators enable the contents of a class to be cycled through via a foreach loop.




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net