using System;
using System.Collections;
public class SamplesHashtable  {   public static void Main()  {      // Create and initialize a new Hashtable.
      Hashtable myHT = new Hashtable();
      myHT.Add("First", "Hello");  //First 是key.Hello是value
      myHT.Add("Second", "World");
      myHT.Add("Third", "!");      // Display the properties and values of the Hashtable.
      Console.WriteLine( "myHT" );
      Console.WriteLine( "  Count:    {0}", myHT.Count ); //键值的数量
      Console.WriteLine( "  Keys and Values:" );
      PrintKeysAndValues( myHT );
   }
   public static void PrintKeysAndValues( Hashtable myList )  {
      IDictionaryEnumerator myEnumerator = myList.GetEnumerator(); //枚举hashTable
      Console.WriteLine( "\t-KEY-\t-VALUE-" );
      while ( myEnumerator.MoveNext() )  //移到下一个键值 
         Console.WriteLine("\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value);
          //key 得到键,value得到键值
      Console.WriteLine();//
   }
}
/* 
Output:myHT
  Count:    3
  Keys and Values:
    -KEY-    -VALUE-
    Third:    !
    Second:    World
    First:    Hello
*/