C# OrderedDictionary RemoveAt

Description

OrderedDictionary RemoveAt removes the entry at the specified index from the OrderedDictionary collection.

Syntax

OrderedDictionary.RemoveAt has the following syntax.


public void RemoveAt(
  int index
)

Parameters

OrderedDictionary.RemoveAt has the following parameters.

  • index - The zero-based index of the entry to remove.

Returns

OrderedDictionary.RemoveAt method returns

Example


using System;/* ww w.j av  a 2s  .c  o 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");
    
        // Modify the value of the entry with the key "testKey2"
        myOrderedDictionary["testKey2"] = "modifiedValue";
    
        // Remove the last entry from the OrderedDictionary: "testKey3"
        myOrderedDictionary.RemoveAt(myOrderedDictionary.Count - 1);
    
        // Remove the "keyToDelete" entry, if it exists
        if (myOrderedDictionary.Contains("keyToDelete"))
        {
            myOrderedDictionary.Remove("keyToDelete");
        }

   }
}




















Home »
  C# Tutorial »
    System.Collections.Specialized »




BitVector32
HybridDictionary
ListDictionary
OrderedDictionary
StringCollection
StringDictionary
StringEnumerator