jo

jo

  • NA
  • 6
  • 3.9k

Comparing 2 dictionaries and removing duplicates

Apr 13 2013 6:44 AM

Hi All,

I have 3 dictionaries. I am trying to compare dict1 and dict2 , remove the same entries from dict1 and sending as an output to dict3.

Dict1= ["Test1", "testing"] ["Test2", "testing76"] ["Test3", "testin67g"] ["Test4", "tests67ing"] ["Test5", "tessadting"] ["Test8", "tessadting"]

Dict2= ["Test1", "testin67g"] ["Test2", "testing 67"] ["test3", "testing6"] ["test4", "testing 213"] ["test7", "testing 21"]

Dict3= ["Test5", "tessadting"] ["Test8", "tessadting"]-------->Output needed

My line of code is,

Dictionary<string,string> dict3= Dict1.Keys.Except(Dict2.Keys).ToDictionary(t => t, t => dict1[t]);

But i dont get the correct output. Kindly help.

Thanks
Jo

 

 


 


 


Answers (2)