My version will be similar to the offer from @Leonid Malyshev. To store the combined information I need the following auxiliary class:
class MergedEntityInfo { public string Name; public string Value1; public string Value2; }
Now suppose that the description format of the property "<name>: <value>" is always respected for both lists, then we will analyze the information stored in the first list:
var mergedEntityInfoMap = (from entityDescription in lst1 let info = entityDescription.Split(':').ToArray() let entity = new MergedEntityInfo { Name = info[0], Value1 = info[1] } select entity) .ToDictionary(x => x.Name);
Next, we will go through the second list and add to the information in mergedEntityInfoMap :
foreach (var info in lst2.Select(x => x.Split(':').ToArray())) { MergedEntityInfo mergedEntityInfo; if (mergedEntityInfoMap.TryGetValue(info[0], out mergedEntityInfo)) { mergedEntityInfo.Value2 = info[1]; } else { mergedEntityInfoMap[info[0]] = new MergedEntityInfo { Name = info[0], Value2 = info[1] }; } }
That's it, mergedEntityInfo contains combined information.