OrderedDictionary.Insert Method (Int32, Object, Object)

 

Inserts a new entry into the OrderedDictionary collection with the specified key and value at the specified index.

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

abstract Insert : 
        index:int *
        key:Object *
        value:Object -> unit
override Insert : 
        index:int *
        key:Object *
        value:Object -> unit

Parameters

index
Type: System.Int32

The zero-based index at which the element should be inserted.

key
Type: System.Object

The key of the entry to add.

value
Type: System.Object

The value of the entry to add. The value can be null.

Exception Condition
ArgumentOutOfRangeException

index is out of range.

NotSupportedException

This collection is read-only.

If the index parameter is equal to the number of entries in the OrderedDictionary collection, the key and value parameters are appended to the end of the collection.

Entries that follow the insertion point move down to accommodate the new entry and the indexes of the moved entries are also updated.

The following code example demonstrates the modification of an OrderedDictionary collection. In this example, the Insert method is used to add a new entry to the beginning of the OrderedDictionary, moving the rest of the entries down. This code is part of a larger code example that can be viewed at OrderedDictionary.

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

Universal Windows Platform
Available since 10
.NET Framework
Available since 2.0
Return to top
Show: