= new Dictionary Dictionary<string, string>() {
{ "key1": "primary" },
{ "key2": "primary" },
{ "key4": "primary" },
{ "key5": "primary" }
};
Dictionary<string, string> secondary = new Dictionary Dictionary<string, string>() {
{ "key1": "secondary" },
{ "key2": "secondary" },
{ "key3": "secondary" },
{ "key6": "secondary" }
};
// Вывод:
Dictionary<string, string> output = new Dictionary Dictionary<string, string>() {
{ "key1": "secondary" },
{ "key2": "secondary" },
{ "key3": "secondary" },
{ "key4": "" },
{ "key5": "" }
{ "key6": "secondary" }
};
https://stackoverflow.com/questions/294138/merging-dictionaries-in-c-sharp Но имхо проще фором, как дед
https://stackoverflow.com/questions/3132113/c-sharp-merging-the-two-dictionaries-with-respect-to-values-using-linq#3132113
Обсуждают сегодня