Merge two lists of objects which hold different data
Posted
by C.McAtackney
on Stack Overflow
See other posts from Stack Overflow
or by C.McAtackney
Published on 2010-06-14T09:47:17Z
Indexed on
2010/06/14
9:52 UTC
Read the original article
Hit count: 231
I have an object "Project" which has a number of fields, one of which is "Name". I have one spreadsheet of projects which contains some of these fields, and another which contains the rest. However, Both spreadsheets have the "Name" field.
I've read them in and populated two List, only populating the available fields from that particular source. E.g. a Project from List 1 looks like; {Name="MyProj", Type="Form", Priority=NULL}, whereas a Project from List 2 {Name="MyProj", Type=NULL, Priority="High"}.
Now, I want to merge these two lists into one in which each Project object has all of its fields populated, with the Name field being used to match the elements.
How can I achieve this? Are there any nice ways of doing this concisely?
Thanks
© Stack Overflow or respective owner