I've done a lot of digging and I can't seem to find an answer to this particular problem; answers to similar problems, but nothing quite like this.
Essentially, what I'm trying to do is take two C# lists, both of which contain a range of C# Objects comprised of string-integer pairs, then merge them together, joining the values of similar Objects.
Let's say my Object Class looks like this;
public class Object
{
public string Name;
public int Value;
}
And we'll also say that my lists look like this;
objectList1 objectList2
Name Value Name Value
Object1 1 Object1 1
Object2 1 Object2 1
Object3 1
Object4 1
Object5 1
My goal here is to combine the contents of objectList2's Objects to the corresponding Objects in objectList1. In this example, that would mean that objectList1 would look like this when all is said and done;
Name Value
Object1 2
Object2 2
Object3 1
Object4 1
Object5 1
Now I know this is possible to do with foreach and FindIndex() calls, but I'm almost positive there's a more efficient way to go about this. If I'm wrong, that's fine, but I'd like to know if I can optimize this because my gut tells me there has to be a simpler way.
foreachcycles. I went with the Dictionaries option because instant location via key values is far more effective in this case.