手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >C#中Dictionary几种遍历的实现代码
C#中Dictionary几种遍历的实现代码
摘要:复制代码代码如下:Dictionarylist=newDictionary;//3.0以上版本foreach(variteminlist){...

复制代码 代码如下:

Dictionary<string,string> list=new Dictionary<string,string>;

//3.0以上版本

foreach(var item in list)

{

Console.WriteLine(item.Key+item.Value);

}

//KeyValuePair<T,K>

foreach(KeyValuePair<string,string> kv in list)

{

Console.WriteLine(kv.Key+kv.Value);

}

//通过键的集合取

foreach(string key in list.Keys)

{

Console.WriteLine(key+list[key]);

}

//for循环遍历

List<string> test=new List<string>(list.Keys);

for(int i=0;i<list.Count;i++)

{

Console.WriteLine(test[i]+list[test[i]]);

}

【C#中Dictionary几种遍历的实现代码】相关文章:

asp.net导出EXCEL的功能代码

asp图片防盗链的代码

.NET 日志系统设计思路及实现代码

asp.net中调用winrar实现压缩解压缩的代码

asp.net保存远程图片的代码

asp.net 操作excel的实现代码

ASP.net Substitution 页面缓存而部分不缓存的实现方法

程序中常用的种代码

.NET 扩展实现代码

asp用户登录模块实例代码

精品推荐
分类导航