Represents a collection of key/value pairs that are accessible by the key or index.
Assembly: System (in System.dll)
Thetype exposes the following members.
|OrderedDictionary()||Initializes a new instance of the class.|
|OrderedDictionary(IEqualityComparer)||Initializes a new instance of the class using the specified comparer.|
|OrderedDictionary(Int32)||Initializes a new instance of the class using the specified initial capacity.|
|OrderedDictionary(Int32, IEqualityComparer)||Initializes a new instance of the class using the specified initial capacity and comparer.|
|OrderedDictionary(SerializationInfo, StreamingContext)||Initializes a new instance of the class that is serializable using the specified SerializationInfo and StreamingContext objects.|
|Count||Gets the number of key/values pairs contained in the collection.|
|IsReadOnly||Gets a value indicating whether the collection is read-only.|
|Item(Int32)||Gets or sets the value at the specified index.|
|Item(Object)||Gets or sets the value with the specified key.|
|Keys||Gets an ICollection object containing the keys in the collection.|
|Values||Gets an ICollection object containing the values in the collection.|
|Add||Adds an entry with the specified key and value into the collection with the lowest available index.|
|AsReadOnly||Returns a read-only copy of the current collection.|
|Clear||Removes all elements from the collection.|
|Contains||Determines whether the collection contains a specific key.|
|CopyTo||Copies the elements to a one-dimensional Array object 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 object that iterates through the collection.|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetObjectData||Implements the ISerializable interface and returns the data needed to serialize the collection.|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|Insert||Inserts a new entry into the collection with the specified key and value at the specified index.|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|OnDeserialization||Implements the ISerializable interface and is called back by the deserialization event when deserialization is complete.|
|Remove||Removes the entry with the specified key from the collection.|
|RemoveAt||Removes the entry at the specified index from the collection.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|AsParallel()||Overloaded. Enables parallelization of a query. (Defined by ParallelEnumerable.)|
|AsParallel()||Overloaded. (Defined by ParallelEnumerable.)|
|AsQueryable()||Overloaded. Converts an IEnumerable to an IQueryable. (Defined by Queryable.)|
|AsQueryable()||Overloaded. (Defined by Queryable.)|
|Cast(TResult)()||Overloaded. Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)|
|Cast(TResult)()||Overloaded. (Defined by Enumerable.)|
|OfType(TResult)()||Overloaded. Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)|
|OfType(TResult)()||Overloaded. (Defined by Enumerable.)|
|ICollection.IsSynchronized||Gets a value indicating whether access to the object is synchronized (thread-safe).|
|ICollection.SyncRoot||Gets an object that can be used to synchronize access to the object.|
|IDeserializationCallback.OnDeserialization||Implements the ISerializable interface and is called back by the deserialization event when deserialization is complete.|
|IDictionary.IsFixedSize||Gets a value indicating whether the has a fixed size.|
|IEnumerable.GetEnumerator||Infrastructure. Returns an IDictionaryEnumerator object that iterates through the collection.|
Each element is a key/value pair stored in a DictionaryEntry object. A key cannot be a null reference (Nothing in Visual Basic), but a value can be.
The elements of an are not sorted by the key, unlike the elements of a SortedDictionary(TKey, TValue) class. You can access elements either by the key or by the index.
The foreach statement of the C# language (For Each in Visual Basic) returns objects that are of the type of each element in the collection. Since each element of the collection 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. The following code shows C#, Visual Basic and C++ syntax.
The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.
The following code example demonstrates the creation, population and modification of an collection, as well as two techniques to display the contents of the : one using the Keys and Values properties and the other creating an enumerator through the GetEnumerator method.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.