Export (0) Print
Expand All
8 out of 9 rated this helpful - Rate this topic

OrderedDictionary Class

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

Namespace:  System.Collections.Specialized
Assembly:  System (in System.dll)
public class OrderedDictionary implements IOrderedDictionary, IDictionary, ICollection, IEnumerable, ISerializable, IDeserializationCallback

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 in any way. OrderedDictionary collections allow access by both index as well as key.

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# and Visual Basic syntax.

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

[Visual Basic, C#]

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.
System.Object
  System.Collections.Specialized.OrderedDictionary
    System.Web.Configuration.AdapterDictionary
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.