[C#]KeyValuePair 和 Dictionary 的关系

KeyValuePair 和 Dictionary 的关系
1、KeyValuePair
    a、KeyValuePair 是一个结构体(struct);
    b、KeyValuePair 只包含一个Key、Value的键值对。
2、Dictionary
    a、Dictionary 可以简单的看作是KeyValuePair 的集合;
    b、Dictionary 可以包含多个Key、Value的键值对。

Console.WriteLine();
foreach( KeyValuePair<string, string> kvp in openWith )
{
    Console.WriteLine("Key = {0}, Value = {1}",
        kvp.Key, kvp.Value);
}

猜你喜欢

转载自blog.csdn.net/weixin_46472622/article/details/131471823
今日推荐