Explained: Collections Explained

From Guidance Share

Jump to: navigation, search

- J.D. Meier, Srinath Vasireddy, Ashish Babbar, Rico Mariani, and Alex Mackman

Collections Explained

There are two basic types of collections: lists and dictionaries. Lists are index-based. Dictionaries are key-based, which means you store a key with the value. Table 5.3 summarizes the various list and dictionary types provided by the .NET Framework class libraries.

Collections are types that implement the IEnumerable, ICollection, or IList interfaces. If the types implement IDictionary separately or in addition to these three interfaces, they are referred to as Dictionaries. Table 5.3 lists the guidelines for each of these collection types.

Table 5.3: List and Dictionary Collection Types




This is a dynamically sizable array. It is useful when you do not know the required array size at design time.


This is a collection of key/value pairs that are organized based on the hash code of the key. It is appropriate when you need to search but not sort.


This uses a ListDictionary when the collection is small, and switches to Hashtable when the collection gets large.


This is useful for storing 10 or less key/value pairs.


This is a sorted collection of associated String keys and String values that can be accessed either with the key or with the index.


This is a first-in, first-out collection that implements ICollection.


This is a collection of key/value pairs that are sorted by the keys and are accessible by key and by index.


This is a simple last-in, first-out collection of objects.


This is a strongly typed array list for strings.


This is a hash table with the key strongly typed to be a string rather than an object.

Personal tools