■
Note
By convention, generic types specify their placeholders using common names. Although any letter (or
word) will do, typically
T
is used to represent types,
TKey
is used for keys, and
TValue
is used for values.
The System.Collections.Generic namespace also defines a number of classes that implement
many of these key interfaces. Table 10-5 describes the core class types of this namespace, the inter-
faces they implement, and any corresponding type in the System.Collections namespace.
Table 10-5.
Classes of System.Collections.Generic
Generic Class in
Nongeneric Counterpart
System.Collections
Meaning in Life
Collection
CollectionBase
The basis for a generic collection
Comparer
Comparer
Compares two generic objects for
equality
Dictionary
Hashtable
A generic collection of
name/value pairs
List
ArrayList
A dynamically resizable list of
items
Queue
Queue
A generic implementation of a
first-in, first-out (FIFO) list
SortedDictionary
SortedList
A generic implementation of a
sorted set of name/value pairs
Stack
Stack
A generic implementation of a
last-in, first-out (LIFO) list
C H A P T E R 1 0
■
C O L L E C T I O N S A N D G E N E R I C S
324
8849CH10.qxd 9/25/07 4:17 PM Page 324
Do'stlaringiz bilan baham: |