System.Collections.Specialized.ListDictionary Class

Implements IDictionary using a singly linked list. Recommended for collections that typically include fewer than 10 items.

See Also: ListDictionary Members


public class ListDictionary : IDictionary


This is a simple implementation of IDictionary using a singly linked list. It is smaller and faster than a Hashtable if the number of elements is 10 or less. This should not be used if performance is important for large numbers of elements.

Items in a System.Collections.Specialized.ListDictionary are not in any guaranteed order; code should not depend on the current order. The System.Collections.Specialized.ListDictionary is implemented for fast keyed retrieval; the actual internal order of items is implementation-dependent and could change in future versions of the product.

Members, such as ListDictionary.Item(object), ListDictionary.Add(object, object), ListDictionary.Remove(object), and ListDictionary.Contains(object) are O(n) operations, where n is ListDictionary.Count.

A key cannot be null, but a value can.

The foreach statement of the C# language (for each in Visual Basic) requires the type of each element in the collection. Since each element of the System.Collections.Specialized.ListDictionary is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is DictionaryEntry. For example:

code reference: System.Collections.Specialized.ListDictionary2#3

The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.


Namespace: System.Collections.Specialized
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,,