Dictionary 的几种遍历方法

Dictionary<string, int>dic = newDictionary<string, int>();
方法1
foreach (var item in dic)
{
Console.WriteLine(dic.Key + dic.Value);
}
方法2
//KeyValuePair<T,K>
foreach (KeyValuePair<string, int> kv in dic)
{
Console.WriteLine(kv.Key + kv.Value);
}
方法3
//通过键的集合取
foreach (string key indic.Keys)
{
Console.WriteLine(key + list[key]);
}

Dictionary 的几种遍历方法的更多相关文章

  1. Dictionary的几种遍历方法

    Dictionary<string, int> list = new Dictionary<string, int>(); list.Add("d", 1) ...

  2. C# Dictionary 的几种遍历方法

    Dictionary<string, int> list = new Dictionary<string, int>(); list.Add("d", 1) ...

  3. C# Dictionary 的几种遍历方法,排序

    Dictionary<string, int> list = new Dictionary<string, int>(); list.Add(); //3.0以上版本 fore ...

  4. javase-常用三种遍历方法

    javase-常用三种遍历方法 import java.util.ArrayList; import java.util.Iterator; import java.util.List; public ...

  5. Java中Map的三种遍历方法

    Map的三种遍历方法: 1. 使用keySet遍历,while循环: 2. 使用entrySet遍历,while循环: 3. 使用for循环遍历.   告诉您们一个小秘密: (下↓面是测试代码,最爱看 ...

  6. Jquery中each的三种遍历方法

    Jquery中each的三种遍历方法 $.post("urladdr", { "data" : "data" }, function(dat ...

  7. java 完全二叉树的构建与四种遍历方法

    本来就是基础知识,不能丢的太干净,今天竟然花了那么长的时间才写出来,记一下. 有如下的一颗完全二叉树: 先序遍历结果应该为:1  2  4  5  3  6  7 中序遍历结果应该为:4  2  5 ...

  8. HashMap的四种遍历方法,及效率比较(简单明了)

    https://yq.aliyun.com/ziliao/210955 public static void main(String[] args) { HashMap<Integer, Str ...

  9. Java List /ArrayList 三种遍历方法

    java list三种遍历方法性能比较http://www.cnblogs.com/riskyer/p/3320357.html JAVA LIST 遍历http://blog.csdn.net/lo ...

随机推荐

  1. Codeforces Round #312 (Div. 2) E. A Simple Task 线段树

    E. A Simple Task 题目连接: http://www.codeforces.com/contest/558/problem/E Description This task is very ...

  2. KrakenD: API Gateway and Manager

    KrakenD: API Gateway and Manager http://www.krakend.io/

  3. STM32 F4 SPI Accelerometer

    STM32 F4 SPI Accelerometer

  4. OAuth2.0网页授权 提示未关注该测试号

    用无高级接口权限的公众号使用别人的appid和appsecret在网页中获取用户信息时,提示未关注该测试号. 搜集各种资料才发现是因为 测试帐号只能对关注者网页授权,正式帐号可以对未关注者授权

  5. [转].net reactor 学习系列(五)---源代码加密程序

    .NET Reactor使用教程(加密源代码示例) 1.打开 Eziriz .NET Reactor,主界面如图1所示: 图1 2.单击 Main Assembly 右边的 Open,选择要加密的软件 ...

  6. CentOS 7.x,不重新编译 PHP,动态安装 imap 扩展

    先前的教程:PHP5不重新编译,如何安装自带的未安装过的扩展,如soap扩展? # 安装依赖包 yum install -y libc-client-devel /usr/local/src/cent ...

  7. 北大 ACM 分类 汇总

    1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...

  8. sigmod2017.org

    http://sigmod2017.org/sigmod-program/#ssession20

  9. 快递 API接口

    http://www.kuaidi.com/openapi.html http://www.kuaidi100.com/ http://www.cnblogs.com/sususu3/p/577642 ...

  10. Spark RDD的fold和aggregate为什么是两个API?为什么不是一个foldLeft?

    欢迎关注我的新博客地址:http://cuipengfei.me/blog/2014/10/31/spark-fold-aggregate-why-not-foldleft/ 大家都知道Scala标准 ...