Export (0) Print
Expand All

IOrderedDictionary Interface

Represents an indexed collection of key/value pairs.

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

public interface class IOrderedDictionary : IDictionary, ICollection, IEnumerable
public interface IOrderedDictionary extends IDictionary, ICollection, 
	IEnumerable
public interface IOrderedDictionary extends IDictionary, ICollection, 
	IEnumerable
Not applicable.

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.

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.

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 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft