ages["John"]=41; 
ages["Jay"]=43; 
ages["Tony"]=13; 
ages["Herry"]=24; 改成:ages.add("John",41); 
ages.add("Jay",43); 
ages.add("Tony",13); 
ages.add("Herry",24);

解决方案 »

  1.   

    DictionEntry
    =======================
    DictionaryEntry
      

  2.   

    DictionEntry 改为DictionaryEntry
      

  3.   

    呵呵  就是拼错了 DictionEntry 改为DictionaryEntry
    using System;
    using System.Collections;
    public class SamplesHashtable  {   public static void Main()  {      // Creates and initializes a new Hashtable.
          Hashtable myHT = new Hashtable();
          myHT.Add( "one", "The" );
          myHT.Add( "two", "quick" );
          myHT.Add( "three", "brown" );
          myHT.Add( "four", "fox" );      // Displays the Hashtable.
          Console.WriteLine( "The Hashtable contains the following:" );
          PrintKeysAndValues( myHT );
       }
       public static void PrintKeysAndValues( Hashtable myHT )  {
          Console.WriteLine( "\t-KEY-\t-VALUE-" );
          foreach ( DictionaryEntry de in myHT )
             Console.WriteLine( "\t{0}:\t{1}", de.Key, de.Value );
          Console.WriteLine();
       }
    }