ASP.NET Dictionary 的基本用法示例介绍
2018-10-12 14:00
696 查看
Dictionary<string, string> o_Dic = new Dictionary<string, string>();
//添加元素
o_Dic.Add("01", "aaa");
o_Dic.Add("02","bbb");
//判断某个key是否存在
if (!o_Dic.ContainsKey("03"))
{
o_Dic.Add("03", "ccc");
}
//移除某个
o_Dic.Remove("03");
//取某个的值
string a = o_Dic["02"];
//遍歷
foreach (KeyValuePair<string, string> kvp in o_Dic)
{
Response.Write(kvp.Key + "," + kvp.Value);
}
//遍歷key
foreach (string s in o_Dic.Keys) { }
//遍歷value
foreach (string s in o_Dic.Values) { }
您可能感兴趣的文章:
相关文章推荐
- ASP.NET Dictionary 的基本用法示例介绍
- ASP.NET Dictionary 的基本用法
- ASP.NET验证控件使用详解,介绍了基本属性和用法
- ASP.NET中Dictionary基本用法实例分析
- ASP.NET中Dictionary基本用法实例分析
- ASP.NET 中反射的用法介绍
- ASP.NET的Web.config基本配置节介绍
- ASP.NET AjaxControlToolkit 的基本用法
- ASP.NET Web API 开篇示例介绍
- CKEditor 3.6 + CKFinder 2.0在Asp.Net中的配置与基本用法
- C#(asp.net)多线程用法示例(可用于同时处理多个任务)
- Control Study -> Asp.net几个较复杂数据控件(Repeater/DataList/DataGrid)用法 (示例代码下载)
- frameset的用法示例(asp.net中的有用框架):
- asp.net __doPostBack详细解释,用法示例
- Asp.Net MVC 2.0 Filter基本用法
- frameset的用法示例(asp.net中的有用框架):
- 最经典介绍ASP.NET抽象工厂模式概念及用法 ~~~转转转转