Section 26.1. Introduction


26.1. Introduction

In chapter 24, we discussed how to create and manipulate data structures. The discussion was "low level" in the sense that we painstakingly created each element of each data structure dynamically with New and modified the data structures by directly manipulating their elements and references to their elements. In this chapter, we consider the prepackaged data-structure classes provided by the .NET Framework. These classes are known as collection classesthey store collections of data. Each instance of one of these classes is a collection of items. Some examples of collections are the cards you hold in a card game, the songs stored in your computer, the real-estate records in your local registry of deeds (which map book numbers and page numbers to property owners), and the players on your favorite sports team.

Collection classes enable you to store sets of items by using existing data structures without concern for how they are implemented. This is a nice example of code reuse. You can code faster and expect excellent performance, maximizing execution speed and minimizing memory consumption. We discuss the collection interfaces that list the capabilities of each collection type, the implementation classes and the enumerators that "walk through" collections.

The .NET Framework provides three collections namespaces. The System.Collections namespace contains collections that store references to Objects. The System.Collections.Generic namespace (new to .NET 2.0) contains generic classes to store collections of specified types. (We introduced generic methods and classes in Chapter 25.) The System.Collections.Specialized namespace (also new to .NET 2.0) contains several collections that support specific types, such as Strings and bits. To learn more about the classes from this namespace, visit

msdn2.microsoft.com/en-us/library/system.collections.specialized.aspx

The collections in these namespaces provide standardized components that are written for broad reuse; you do not need to write your own collection classes.



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

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