I have 2 IEnumerable<KeyValuePair<TreeType, int>>
collections:
- _myObject.Trees - contains all the TreeTypes with values of 0.
- newTrees - can contain any number of TreeTypes with any int value.
Now what I want to do is simple but I've been trying for hours and can't quite get the desired results. I want to insert the newTrees values into the _myobject.Trees collection, so that the _myObject.Trees values won't all be 0.
The closest I've got is below. I know why this doesn't work, but again, I just can't see the solution.
foreach (var tree in _myObject.Trees)
{
foreach (var newTree in newTrees)
{
if (tree.Key == newTree.Key)
{
_myObject.Trees[tree] =
new KeyValuePair<TreeType, int>(newTree.Key, newTree.Value);
break;
}
}
}
Would really appreciate the help, thanks!