本帖最后由 happytor 于 2009-07-22 08:28:11 编辑

解决方案 »

  1.   

     private static void display(Hashtable ht)
            {
                foreach(DictionaryEntry de in ht)
                {
                    Console.WriteLine(de.Key);
                    Console.WriteLine(de.Value);
                }
            }
     display(ht);
      

  2.   

    先找本基础的书看下吧class Program
        {
            private static void display(Hashtable ht)
            {
                foreach(DictionaryEntry de in ht)
                {
                    Console.WriteLine(de.Key);
                    Console.WriteLine(de.Value);
                }
            }
            public static void Main(string[] args)
            {
                //Console.WriteLine("Hello World!");
                Hashtable ht=new Hashtable();
                
                ht.Add("E","e");
                ht.Add("A","a");
                ht.Add("C","c");
                ht.Add("B","b");
                
                display(ht);
                string s=(string)ht["A"];
                if(ht.Contains("E"))
                    Console.WriteLine("the E key exist");
                ht.Remove("C");
                Console.WriteLine(ht["A"]);
                ht.Clear();
                Console.WriteLine(ht["A"]);
                
                
                Console.Write("Press any key to continue . . . ");
                Console.ReadKey(true);
            }
        }如果前面没加
    using System.Collections;
    别忘了加上
      

  3.   


    private void display(Hashtable ht)
            {
                for(DictionaryEntry de in ht)
                {
                    Console.WriteLine(de.Key);
                    Console.WriteLine(de.Value);
                }
            }应该是:private static void display(Hashtable ht)
            {
                foreach(DictionaryEntry de in ht)
                {
                    Console.WriteLine(de.Key);
                    Console.WriteLine(de.Value);
                }
            }