foreach(DictoryEntry de in YHashTable)

解决方案 »

  1.   

    Hashtable ages = new Hashtable();
                ages["a"]=41;
                ages["b"] = 42;
                ages["c"] = 11;
                ages["d"] = 13;
               
                foreach (DictionaryEntry element in ages)
                {
                    string name = (string)element.Key;
                    int age = (int)element.Value;
                    Console.WriteLine(name, age);            }
      

  2.   

    通过Keys来得到它的所有键值,比如:
    Hashtable tb;
    ...
    foreach (object o in tb.Keys)
    {
    System.Console.WriteLine(o);
    }
      

  3.   

    Hashtable myHT = new Hashtable();
    myHT.Add("1", "Hello");
    myHT.Add("2", "World");
    myHT.Add("3", "!"); Foreach(IDictionaryEnumerator Enum in HT)
       {
        Enum .Key;
        Enum .Value;
       }