龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp.net编程 >

ASP.NET 2.0 使用Dictionary

时间:2009-12-21 11:47来源:未知 作者:admin 点击:
分享到:
由于使用了范型,操作变得相当简单 新建一个 protected Dictionarystring, ISectionControl SectionControlDictionary = new Dictionarystring, ISectionControl(); 使用 SectionControlDictionary.Add("SectionBoard", mSectionBoardU
由于使用了范型,操作变得相当简单

新建一个

protected Dictionary<string, ISectionControl> SectionControlDictionary = new Dictionary<string, ISectionControl>();

使用

SectionControlDictionary.Add("SectionBoard", mSectionBoardUserControl);

遍历

foreach (KeyValuePair<string, List<object>> de in SectionDictionary)
{
     SectionControlDictionary[de.Key].ReBind(de.Value);
}

[separator]


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

精彩图集

赞助商链接