Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

IOrderedDictionary Interface

Represents an indexed collection of key/value pairs.

Namespace:  System.Collections.Specialized
Assembly:  System (in System.dll)
type IOrderedDictionary =  
    interface 
        interface IDictionary 
        interface ICollection 
        interface IEnumerable 
    end

The IOrderedDictionary type exposes the following members.

  NameDescription
Public propertyCountGets the number of elements contained in the ICollection. (Inherited from ICollection.)
Public propertyIsFixedSizeGets a value indicating whether the IDictionary object has a fixed size. (Inherited from IDictionary.)
Public propertyIsReadOnlyGets a value indicating whether the IDictionary object is read-only. (Inherited from IDictionary.)
Public propertyIsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from ICollection.)
Public propertyItem(Int32)Gets or sets the element at the specified index.
Public propertyItem(Object)Gets or sets the element with the specified key. (Inherited from IDictionary.)
Public propertyKeysGets an ICollection object containing the keys of the IDictionary object. (Inherited from IDictionary.)
Public propertySyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from ICollection.)
Public propertyValuesGets an ICollection object containing the values in the IDictionary object. (Inherited from IDictionary.)
Top
  NameDescription
Public methodAddAdds an element with the provided key and value to the IDictionary object. (Inherited from IDictionary.)
Public methodClearRemoves all elements from the IDictionary object. (Inherited from IDictionary.)
Public methodContainsDetermines whether the IDictionary object contains an element with the specified key. (Inherited from IDictionary.)
Public methodCopyToCopies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from ICollection.)
Public methodGetEnumeratorReturns an enumerator that iterates through the IOrderedDictionary collection.
Public methodInsertInserts a key/value pair into the collection at the specified index.
Public methodRemoveRemoves the element with the specified key from the IDictionary object. (Inherited from IDictionary.)
Public methodRemoveAtRemoves the element at the specified index.
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

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. Because 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, as the following example shows.

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.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.