Insert entry into OrderedDictionary with key and value at the specified index in CSharp
Description
The following code shows how to insert entry into OrderedDictionary with key and value at the specified index.
Example
using System;/*from w w w .j av a 2 s .co m*/
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringCollection {
public static void Main() {
OrderedDictionary myOrderedDictionary = new OrderedDictionary();
myOrderedDictionary.Add("testKey1", "testValue1");
myOrderedDictionary.Add("testKey2", "testValue2");
myOrderedDictionary.Add("testKey3", "testValue3");
myOrderedDictionary.Insert(0, "insertedKey1", "insertedValue1");
Console.WriteLine(myOrderedDictionary.Contains("insertedKey1"));
}
}
The code above generates the following result.