Export (0) Print
Expand All

OrderedDictionary Class

Represents a collection of key/value pairs that are accessible by the key or index.

System.Object
  System.Collections.Specialized.OrderedDictionary
    System.Web.Configuration.AdapterDictionary

Namespace:  System.Collections.Specialized
Assembly:  System (in System.dll)

[<SerializableAttribute>]
type OrderedDictionary =  
    class 
        interface IOrderedDictionary 
        interface IDictionary 
        interface ICollection 
        interface IEnumerable 
        interface ISerializable 
        interface IDeserializationCallback 
    end

The OrderedDictionary type exposes the following members.

  NameDescription
Public methodOrderedDictionary()Initializes a new instance of the OrderedDictionary class.
Public methodOrderedDictionary(IEqualityComparer)Initializes a new instance of the OrderedDictionary class using the specified comparer.
Public methodOrderedDictionary(Int32)Initializes a new instance of the OrderedDictionary class using the specified initial capacity.
Public methodOrderedDictionary(Int32, IEqualityComparer)Initializes a new instance of the OrderedDictionary class using the specified initial capacity and comparer.
Protected methodOrderedDictionary(SerializationInfo, StreamingContext)Initializes a new instance of the OrderedDictionary class that is serializable using the specified SerializationInfo and StreamingContext objects.
Top

  NameDescription
Public propertyCountGets the number of key/values pairs contained in the OrderedDictionary collection.
Public propertyIsReadOnlyGets a value indicating whether the OrderedDictionary collection is read-only.
Public propertyItem(Int32)Gets or sets the value at the specified index.
Public propertyItem(Object)Gets or sets the value with the specified key.
Public propertyKeysGets an ICollection object containing the keys in the OrderedDictionary collection.
Public propertyValuesGets an ICollection object containing the values in the OrderedDictionary collection.
Top

  NameDescription
Public methodAddAdds an entry with the specified key and value into the OrderedDictionary collection with the lowest available index.
Public methodAsReadOnlyReturns a read-only copy of the current OrderedDictionary collection.
Public methodClearRemoves all elements from the OrderedDictionary collection.
Public methodContainsDetermines whether the OrderedDictionary collection contains a specific key.
Public methodCopyToCopies the OrderedDictionary elements to a one-dimensional Array object at the specified index.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an IDictionaryEnumerator object that iterates through the OrderedDictionary collection.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetObjectDataImplements the ISerializable interface and returns the data needed to serialize the OrderedDictionary collection.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInsertInserts a new entry into the OrderedDictionary collection with the specified key and value at the specified index.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnDeserializationImplements the ISerializable interface and is called back by the deserialization event when deserialization is complete.
Public methodRemoveRemoves the entry with the specified key from the OrderedDictionary collection.
Public methodRemoveAtRemoves the entry at the specified index from the OrderedDictionary collection.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast(TResult)Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType(TResult)Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to the OrderedDictionary object is synchronized (thread-safe).
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to the OrderedDictionary object.
Explicit interface implemetationPrivate methodIDeserializationCallback.OnDeserializationImplements the ISerializable interface and is called back by the deserialization event when deserialization is complete.
Explicit interface implemetationPrivate propertyIDictionary.IsFixedSizeGets a value indicating whether the OrderedDictionary has a fixed size.
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorInfrastructure. Returns an IDictionaryEnumerator object that iterates through the OrderedDictionary collection.
Top

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 OrderedDictionary 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) requires the type of each element in the collection. Since each element of the OrderedDictionary 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.

No code example is currently available or this language may not be supported.

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 OrderedDictionary collection, as well as two techniques to display the contents of the OrderedDictionary: one using the Keys and Values properties and the other creating an enumerator through the GetEnumerator method.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft