This documentation is archived and is not being maintained.

IOrderedDictionary Interface

Represents an indexed collection of key/value pairs.

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

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

IOrderedDictionary elements can be accessed either with the key or with the index.

Each element is a key/value pair stored in a DictionaryEntry structure.

Each pair must have a unique key that is not a null reference (Nothing in Visual Basic), but the value can be a null reference (Nothing in Visual Basic) and does not have to be unique. The IOrderedDictionary interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order.

[Visual Basic, C#]

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 IDictionary 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:

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 allows only reading from, not writing to, the collection.

Notes to Implementers:

The implementing class must have a means to compare keys.

The following code example demonstrates the implementation of a simple IOrderedDictionary based on the ArrayList class. The implemented IOrderedDictionary stores first names as the keys and last names as the values, with the added requirement that each first name is unique.

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

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
Show: