使用 IDictionaryEnumerator 取出 HashTable 的值

  • 1033
  • 0
  • C#
  • 2012-10-23

摘要:使用 IDictionaryEnumerator 取出 HashTable 的值


        static void Main(string[] args)
        {
            Hashtable hash = new Hashtable();
            hash.Add("Jn", "January");
            hash.Add("Fb", "February");
            hash.Add("Mr", "March");
            hash.Add("Ap", "April");
            hash.Add("Jun", "June");
            hash.Add("Jl", "July");
            
            LoopHashtable(hash);
        }

        private static void LoopHashtable(Hashtable hash)
        {
            IDictionaryEnumerator ide = hash.GetEnumerator();

            while (ide.MoveNext())
            {
                Console.WriteLine("Key: {0} Value: {1}", ide.Key, ide.Value);
            }
        }

來源:http://www.dotnetcurry.com/ShowArticle.aspx?ID=748