c# - Comparing two dictionaries and returning the differences in another dictionary -
i have 2 dictionaries , wish compare 2 dictionaries key / pair values. when compare them if value different in second dictionary want keep pairing , store dictionary3.
so if have dictionary 1 (<1,t><2,t><3,t>
) , 2 (<1,t><2,f><3,t>
) want 3 (<2,f>
).
i not sure start one. have dictionaries getting data right not sure how set compare.
private dictionary<int, bool> comparedictionaries(dictionary<int, bool> dic2) { dictionary<int,bool> dictionary3 = new dictionary<int,bool>(); foreach (keyvaluepair<int, bool> pair in dictionary1) { // keep keyvaluepair of dic2 // dictionary3.add(keyvaluepair of dic 2) } return dictionary3; }
any on appreciated. pretty positive can accomplish goal dictionaries. down line after 3rd dictionary going update information in table , refresh list displaying part easier figure out methods , algorithm need part. very appreciated. thank guys.
var dict3 = dict2.except(dict1).todictionary(x => x.key, x => x.value);
Comments
Post a Comment