using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, Dictionary<string, Person>> dicFull = Person.GetFullDic();

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
Dictionary<string, Person> dicPerson = dicFull["South"];
Person person = dicPerson["15"];
Console.WriteLine(person.Province + "," + person.Id + "," + person.Name + "," + person.Age);
sw.Stop();
Console.WriteLine("Cost " + sw.ElapsedMilliseconds.ToString()+" milliseconds");
Console.ReadLine();
}

}

public class Person
{
public string Province { get; set; }
public string Id { get; set; }

public string Name { get; set; }

public string Age { get; set; }

public static Dictionary<string,Person> GetDic()
{
Dictionary<string, Person> dicPerson = new Dictionary<string, Person>();
for(int i=0;i<10;i++)
{
var key = i.ToString();
Person value = new Person()
{
Province = "SH",
Id = i.ToString(),
Name = "Fred" + i,
Age = "Age" + i
};
dicPerson.Add(key, value);
}

for(int i=10;i<20;i++)
{
var key = i.ToString();
Person value = new Person()
{
Province = "JS",
Id = i.ToString(),
Name = "WYQ" + i,
Age = "Age" + i
};

dicPerson.Add(key, value);
}

return dicPerson;
}

public static Dictionary<string,Dictionary<string,Person>> GetFullDic()
{
Dictionary<string, Dictionary<string, Person>> dic = new Dictionary<string, Dictionary<string, Person>>();
Dictionary<string, Person> dicPerson = Person.GetDic();
var key1 = "North";
dic.Add(key1, dicPerson);
var key2 = "South";
dic.Add(key2, dicPerson);

return dic;
}
}
}

Dictionary<string, Dictionary<string, Person>> dic = new Dictionary<string, Dictionary<string, Person>>();的更多相关文章

  1. python 数据类型: 字符串String / 列表List / 元组Tuple / 集合Set / 字典Dictionary

    #python中标准数据类型 字符串String 列表List 元组Tuple 集合Set 字典Dictionary 铭记:变量无类型,对象有类型 #单个变量赋值 countn00 = '; #整数 ...

  2. Java-集合-第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; 其中,classNum 表示学生的班号,例如“class05”。 有如下List List list = new ArrayList(); l

    第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; ...

  3. 第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; 其中,classNum 表示学生的班号,例如“class05”。 有如下List List list = new ArrayList();

    list.add(new Student("Tom", 18, 100, "class05")); list.add(new Student("Jer ...

  4. [BTS] Error biztalk arguments null exception string reference not set to an instance of a string. parameter name

    biztalk arguments null exception string reference not set to an instance of a string. parameter name ...

  5. String详解, String和CharSequence区别, StringBuilder和StringBuffer的区别 (String系列之1)

    本章主要介绍String和CharSequence的区别,以及它们的API详细使用方法. 转载请注明出处:http://www.cnblogs.com/skywang12345/p/string01. ...

  6. 已知有一个Worker 类如下:  public class Worker  { private int age;  private String name;  private double salary;  public Worker (){}  public Worker (String nam

    package homework006; public class Worker { private int age; private String name; private double sala ...

  7. 有如下Student 对象,  private String name;       private int age;       private int score;   private String classNum;  其中,classNum

    package homework003; import java.util.ArrayList; import java.util.List; public class Text { public s ...

  8. 第三题 有如下Student 对象,  private String name;       private int age;       private int score;   private String classNum;  其中,classNum&

    //Student package zuoye; public class Student { private String name; private int age; private int sc ...

  9. 将String转化成Stream,将Stream转换成String

    using System;using System.IO;using System.Text;namespace CSharpConvertString2Stream{     class Progr ...

  10. getParameterMap()的返回值为Map<String, String[]>,从其中取得请求参数转为Map<String, String>的方法如下:

    直接遍历报错:[Ljava.lang.String;@44739f3f Map<String, String> tempMap = new HashMap<String, Strin ...

随机推荐

  1. bat脚本弹出消息示例(msg命令详细解释)

    弹出消息的bat,其实就是通过批处理调用msg命令,msg是系统自在的一个可以发送信息的命令. 示例: @echo off rem 测试MSG msg * "ok" rem 测试M ...

  2. 17、DNS服务器

    DNS     domain  name system   域名系统   [root@li ~]# vim /etc/nsswitch.conf hosts:      files dns --涉及到 ...

  3. FCOS及其和Faster R-CNN的区别

    RetinaNet,SSD,YOLOv3,Faster R-CNN等都是Anchor-based的检测器,即需要预定义的Anchor boxes来进行训练.FCOS是一种Anchor-free和Pro ...

  4. 笔记4:WEB服务器

    web服务器 1 HTTP协议 http:超文本传输协议,基于tcp的方式,会更稳当更安全.协议就是规定了怎样去请求服务器,服务器如何返回信息.如下图红色方框标记所示: 打开浏览器电商广告原理: 我们 ...

  5. React 借助pubsub-js进行兄弟组件的传递值

    1===> raect中两个 兄弟组件 互相通信使用的技术 使用 消息订阅(subscribe)和发布(publish)机制 s儿 伯 s rai b pʌ b lɪ ʃ 有一个库可以处理 Pu ...

  6. 06webpack-- html-webpack-plugin的2个作用

    <!-- 15 html-webpack-plugin的2个作用 下载 cnpm i html-webpack-plugin -D 作用在==>内存中生成页面 在webpack中 导入在内 ...

  7. MySQL拓展 视图,触发器,事务,存储过程,内置函数,流程控制,索引,慢查询优化,数据库三大设计范式

    视图: 1.什么是视图 视图就是通过查询得到一张虚拟表,然后保存下来,下次直接使用即可 2.为什么要用视图 如果要频繁使用一张虚拟表,可以不用重复查询 3.如何使用视图 create view tea ...

  8. 图学Kubernetes

    所有图片来自:Kubernetes Patterns: Reusable Elements for Designing Cloud-Native Applications 本文图片摘要曾经在某大厂内网 ...

  9. 人工智能头条(公开课笔记)+AI科技大本营——一拨微信公众号文章

    不错的 Tutorial: 从零到一学习计算机视觉:朋友圈爆款背后的计算机视觉技术与应用 | 公开课笔记 分享人 | 叶聪(腾讯云 AI 和大数据中心高级研发工程师) 整    理 | Leo 出   ...

  10. zz独家专访AI大神贾扬清:我为什么选择加入阿里巴巴?

    独家专访AI大神贾扬清:我为什么选择加入阿里巴巴? Natalie.Cai 拥有的都是侥幸,失去的都是人生 ​关注她 5 人赞同了该文章 本文由 「AI前线」原创,原文链接:独家专访AI大神贾扬清:我 ...