I'm bit new to c# and want to identify keys that doesn't have same value while comparing two dictionaries.
The dictionary I have is of dict => KeyValuePair<string, string>. And I have two dictionaries like -
dict1 => {"a":"False","b":"amazonaws.com","c":"True"}
dict2 => {"a":"True","b":"amazonaws.com","c":"False"}
I want to compare both dictionaries and return a variable which will have Keys ["a", "c"] as for the above example, those keys have different value.
Currently the logic I have written will only differentiate keys that's not there in the other dictionary.
Dictionary dictExcept = null;
foreach (IDictionary kvp in dict1.Cast<object>().Where(kvp => !dict2.Contains(kvp)))
{
dictExcept.Add(kvp.Keys, kvp.Values);
}
return dictExcept ;