Collections

The Collections namespace is part of the System namespace. It provides a series of classes that implement advanced array features. While the capability to make an a rray of existing types is powerful, sometimes more power is needed in the array itself. The capability to inherently sort or dynamically add dissimilar objects in an array is provided by the classes of the Collections namespace. This namespace contains a specialized set of objects that can be instantiated for additional features when working with a collection of similar objects. Table 7.1 defines several of the objects that are available as part of the System.Collections namespace.

Table 7.1 Collection Classes

Class Description
ArrayList Implements an array whose size increases automatically as elements are added.
BitArray Manages an array of Booleans that are stored as bit values.
Hashtable Implements a collection of values organized by key. Sorting is done based on a hash of the key.
Queue Implements a first in, first out collection.
SortedList Implements a collection of values with associated keys. The values are sorted by key and are accessible by key or index.
Stack Implements a last in, first out collection.

Each of the objects listed focuses on storing a collection of objects. This means that in addition to the special capabilities each provides, it also provides one additional capability not available to objects created based on the Array class. Because every variable in .NET is based ...

Get Professional Visual Basic 2012 and .NET 4.5 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.