zoukankan      html  css  js  c++  java
  • .net里面的字典Dictionary

                Dictionary<int, string> d = new Dictionary<int, string>();
                d.Add(1, "wjl");
                d.Add(2, "zhangsan");
                d.Add(3, "hyf");
                //Dictionary里面可以添加不同键相同值
                d.Add(4, "hyf");
                //检测集合里面是否包含一个键
                if (!d.ContainsKey(4))
                {
                    d.Add(5, "ljm");
                }
                else {
                    d[5] = "王狗蛋儿";
                }
                //遍历字典的两种方式
                foreach (int key  in d.Keys) {
                    Console.WriteLine("键:{0}   值:{1}", key,d[key]);
                }
                Console.WriteLine("********************************");
                foreach (KeyValuePair<int,string> kv in d)
                {
                    Console.WriteLine("键:{0}   值:{1}", kv.Key, kv.Value);
                }

  • 相关阅读:
    细说Cookie(转)
    Custom Exception in ASP.NET Web API 2 with Custom HttpResponse Message
    内核中的定时器
    ibus拼音安装_ubuntu10.04
    linux模块
    zebra/quagga线程分析
    vim常用配置
    rar安装和使用
    zebra/quagga
    netsnmp编译动态库
  • 原文地址:https://www.cnblogs.com/netlws/p/8849344.html
Copyright © 2011-2022 走看看