本文實例講述了C#使用foreach遍歷哈希表(hashtable)的方法。分享給大家供大家參考。具體實現方法如下:
using System;using System.Collection;namespace HashSampleApplication1{ class Program { static void Main() { Hashtable hash = new Hashtable(); hashtable[1] = "kaka"; hashtable[2] = "biryani"; hashtable[13] = "kadai"; foreach (string key in hash.Keys) { Console.WriteLine(key+'='+hash[key]); } } }}
希望本文所述對大家的C#程序設計有所幫助。
新聞熱點
疑難解答