I have two dictionaries like
Dictionary<String, String> one = new Dictionary<string, string>
{
{ "A", "1" },
{ "B", "2" },
{ "C", "3" },
{ "D", "4" },
{ "E", "5" },
{ "F", "6" },
{ "G", "7" },
{ "H", "8" }
};
Dictionary<String, String> two = new Dictionary<string, string>
{
{ "A", "1" },
{ "B", "2" },
{ "C", "3" },
{ "E", "4" },
{ "F", "4" },
{ "I", "6" },
{ "J", "10" },
{ "K", "11" }
};
i need to merge the two dictionary in key level and then in value level and to add the resulting dictionary into the new dictionary three
, the resulting dictionary should not have same keys or same values and in this case the resulting dictionary is like
Dictionary<String, String> three = new Dictionary<string, string>
{
{ "A", "1" },
{ "B", "2" },
{ "C", "3" },
{ "D", "4" },
{ "E", "5" },
{ "F", "6" },
{ "G", "7" },
{ "H", "8" },
{ "J", "10" },
{ "K", "11" }
};
Now i'm using like
- Union all the keys in the two dictionaries
- Creating a new dictionary with the new keys
- removing the dupicate values( same values )
EDIT: if both the dictionaries having same key value pair then i need to store the the key value pair from the first dictionary .
is there any way to do this using LINQ? Thanks in advance