C# OrderedDictionary Add

Description

OrderedDictionary Add adds an entry with the specified key and value into the OrderedDictionary collection with the lowest available index.

Syntax

OrderedDictionary.Add has the following syntax.


public void Add(
  Object key,
  Object value
)

Parameters

OrderedDictionary.Add has the following parameters.

  • key - The key of the entry to add.
  • value - The value of the entry to add. This value can be null.

Returns

OrderedDictionary.Add method returns

Example


using System;/*w  w  w .  j  a v  a 2  s.  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("keyToDelete", "valueToDelete");
        myOrderedDictionary.Add("testKey3", "testValue3");
        Console.WriteLine( myOrderedDictionary.Count);
   }
}




















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




BitVector32
HybridDictionary
ListDictionary
OrderedDictionary
StringCollection
StringDictionary
StringEnumerator