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. 图片在View中的几种填充方式

    UIViewContentMode各类型效果   UIViewContentMode typedef enum {     UIViewContentModeScaleToFill,     UIVi ...

  2. 笔记8:Linux知识

    linux学习笔记 1 Linux介绍 1.1 基本知识 应用领域:服务器使用 LAMP(Linux + Apache + MySQL + PHP)或 LNMP(Linux + Nginx+ MySQ ...

  3. adb命令之解锁打卡

    adb devicesadb shell input keyevent 26                       按手机电源键adb shell input swipe 400 1080 40 ...

  4. 201871010117-石欣钰《面向对象程序设计(JAVA)》第十四周学习总结

    项目 内容 这个作业属于哪个课程 <https://home.cnblogs.com/u/nwnu-daizh/> 这个作业的要求在哪里 <https://www.cnblogs.c ...

  5. 201871010133-赵永军《面向对象程序设计(java)》第十三周学习总结

    201871010133-赵永军<面向对象程序设计(java)>第十三周学习总结 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ ...

  6. python GIL全局解释器锁,多线程多进程效率比较,进程池,协程,TCP服务端实现协程

    GIL全局解释器锁 ''' python解释器: - Cpython C语言 - Jpython java ... 1.GIL: 全局解释器锁 - 翻译: 在同一个进程下开启的多线程,同一时刻只能有一 ...

  7. tensorflow 待阅读的资料

    tensorflow性能调优实践 https://www.jianshu.com/p/937a0ce99f56 2018.04.01 Deep Learning 之 最优化方法 https://blo ...

  8. zz姚班天才少年鬲融凭非凸优化研究成果获得斯隆研究奖

    姚班天才少年鬲融凭非凸优化研究成果获得斯隆研究奖 近日,美国艾尔弗·斯隆基金会(The Alfred P. Sloan Foundation)公布了2019年斯隆研究奖(Sloan Research ...

  9. LeetCode 153. Find Minimum in Rotated Sorted Array寻找旋转排序数组中的最小值 (C++)

    题目: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. ( ...

  10. VIJOS-P1292 火车票

    JDOJ 1404: VIJOS-P1292 火车票 https://neooj.com/oldoj/problem.php?id=1404 Description 一个铁路线上有n(2< =n ...