Implements IDictionary using a singly linked list. Recommended for collections that typically contain 10 items or less.
Assembly: System (in System.dll)
Thetype exposes the following members.
|Count||Gets the number of key/value pairs contained in the .|
|IsFixedSize||Gets a value indicating whether the has a fixed size.|
|IsReadOnly||Gets a value indicating whether the is read-only.|
|IsSynchronized||Gets a value indicating whether the is synchronized (thread safe).|
|Item||Gets or sets the value associated with the specified key.|
|Keys||Gets an ICollection containing the keys in the .|
|SyncRoot||Gets an object that can be used to synchronize access to the .|
|Values||Gets an ICollection containing the values in the .|
|Add||Adds an entry with the specified key and value into the .|
|Clear||Removes all entries from the .|
|Contains||Determines whether the contains a specific key.|
|CopyTo||Copies the entries to a one-dimensional Array instance at the specified index.|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetEnumerator||Returns an IDictionaryEnumerator that iterates through the .|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|Remove||Removes the entry with the specified key from the .|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|AsParallel||Enables parallelization of a query. (Defined by ParallelEnumerable.)|
|AsQueryable||Converts an IEnumerable to an IQueryable. (Defined by Queryable.)|
|Cast(TResult)||Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)|
|OfType(TResult)||Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)|
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 are not in any guaranteed order; code should not depend on the current order. The is implemented for fast keyed retrieval; the actual internal order of items is implementation-dependent and could change in future versions of the product.
A key cannot be a null reference (Nothing in Visual Basic), 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 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:
The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the SyncRoot property.
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.