Assembly: System (in System.dll)
Thetype exposes the following members.
|HybridDictionary()||Creates an empty case-sensitive .|
|HybridDictionary(Boolean)||Creates an empty with the specified case sensitivity.|
|HybridDictionary(Int32)||Creates a case-sensitive with the specified initial size.|
|HybridDictionary(Int32, Boolean)||Creates a with the specified initial size and case sensitivity.|
|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 class is recommended for cases where the number of elements in a dictionary is unknown. It takes advantage of the improved performance of a ListDictionary with small collections, and offers the flexibility of switching to a Hashtable which handles larger collections better than ListDictionary.
If the initial size of the collection is greater than the optimal size for a ListDictionary, the collection is stored in a Hashtable to avoid the overhead of copying elements from the ListDictionary to a Hashtable.
The constructor accepts a Boolean parameter that allows the user to specify whether the collection ignores the case when comparing strings. If the collection is case-sensitive, it uses the key's implementations of Object.GetHashCode and Object.Equals. If the collection is case-insensitive, it performs a simple ordinal case-insensitive comparison, which obeys the casing rules of the invariant culture only. By default, the collection is case-sensitive. For more information on the invariant culture, see System.Globalization.CultureInfo.
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 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
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
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.