C# KeyValuePair<TKey,TValue> 与 Dictionary<TKey,TValue> 区别与联系
【区别】
KeyValuePair
- 可以设置、查询的一对键值 是struct
Dictionary
- 可以设置、查询的多对键值的集合
【除了区别,还有联系】
KeyValuePair是Dictionary集合元素类型的对象
foreach( KeyValuePair kvp in myDictionary )
{
Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
可以通过List
转自并改写:https://www.cnblogs.com/Alicia-meng/p/13574845.html