namespace @string
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable HS = new Hashtable();
            HS.Add(1, "apple");//add 方法是想添加键值对
            HS.Add(2, "orange");
            HS.Add(3, "watermelon");
            HS.Add(4, "banana");
            HS.Add(5, "grape");
            HS.Add(6, "melon");
            foreach (DictionaryEntry de in HS)//dictionaryEntry是这个hashtable的入口点
            {
                Console.WriteLine(de.Value.ToString());
                Console.WriteLine(de.Key.ToString());
            }
        }
    }
}
以上代码实现遍历整个HashTable。res3
posted on 2009-04-21 16:34  Jerryzhang  阅读(399)  评论(0编辑  收藏  举报