From:http://hi.baidu.com/hn1234/blog/item/5361e603358df2ec08fa93d0.html
*******************************************************************
IDictionaryEnumerator enumerator 
= thProduct.GetEnumerator(); 
   
while (enumerator.MoveNext())
{
    arrKey.Add(
"@"+enumerator.Key.ToString());         // Hashtable关健字
    arrValue.Add(enumerator.Value.ToString());            // Hashtable值
}

//定义Hashtable
Hashtable Info = new Hashtable()

//给Hashtable赋值
Info.Add("username","tiger");
Info.Add("email","tiger@tiger.com");
Info.Add("qq","888888");

//遍历Hashtable中的值并输出
foreach (DictionaryEntry each in Info)
{
    Response.Write(each.Key.ToString() + " == " + each.Value.ToString() + "<br />");
}

//输出文字为:
username = tiger
email = tiger@tiger.com
qq = 888888

 

using System.Collections;
 
HashTable objHasTab;
 
// Setting values to objHasTab
 
foreach (DictionaryEntry objDE in objHasTab)
{
    Console.WriteLine(objDE.Key.ToString());
    Console.WriteLine(objDE.Value.ToString());
}
posted on 2006-12-14 10:26  phantom_fox  阅读(489)  评论(0)    收藏  举报