c# - Checking the value of a word in different dictionary then in the loop -
i've got 2 dictionaries, looking through 1 of them , want math if value of same key in other dictionary more 5.
how can make if statement correctly?
foreach (var word in dict1) { temp = word.value; // this: if (temp in dict2 > 5) { *= temp; } else { // nothing } }
if using dictionary both dict1 , dict2:
foreach(var word in dict1.where(w=>dict2.containskey(w.key) && dict2[w.key]>5)) { //dowork }
this iterates items in dict1 have value greater 5 in dict2 , work.
edit: added dict2.containskey(w.key) check in clause since possible dict2 won't contain key in dict1.
Comments
Post a Comment