Create empty StringDictionary in CSharp

Description

The following code shows how to create empty StringDictionary.

Example


using System;//from  w w w  . ja v a 2  s . c  om
using System.Collections;
using System.Collections.Specialized;

public class SamplesStringDictionary  {
   public static void Main()  {
      StringDictionary myCol = new StringDictionary();
      myCol.Add( "red", "rojo" );
      myCol.Add( "green", "verde" );
      myCol.Add( "blue", "azul" );

      String[] myKeys = new String[myCol.Count];
      myCol.Keys.CopyTo( myKeys, 0 );

      for ( int i = 0; i < myCol.Count; i++ ){
         Console.WriteLine(myKeys[i] + "" + myCol[myKeys[i]] );
      }
   }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary