KeyValuePair 和 Dictionary 的关系

KeyValuePair 和 Dictionary 的关系
1、KeyValuePair 
    a、KeyValuePair 是一个结构体(struct);
    b、KeyValuePair 只包含一个Key、Value的键值对。
2、Dictionary 
    a、Dictionary 可以简单的看作是KeyValuePair 的集合;
    b、Dictionary 可以包含多个Key、Value的键值对。
1 Dictionary<int, string> myDic = new Dictionary<int, string>();
2 foreach (KeyValuePair<int, string> item in myDic)
3 {
4     Console.WriteLine("Key = {0}, Value = {1}", item.Key, item.Value);
5 }

转载于 https://blog.csdn.net/aphy358/article/details/50039099

原文地址:https://www.cnblogs.com/Darren-xia/p/14053126.html