-1

I need to create one list (l_merged) from 2 lists (l1, l2) by merging the value of their properties (prop1, prop2).

var l1 = new List<string> { "key1", "key2", "prop1" };
var l2 = new List<string> { "key1", "key2", "prop2" };
var l_merged = new List<string> { "key1", "key2", "prop1", "prop2" };

Where l1.key1 == l2.key && l1.key == l2.key2

Any idea? thank you.

1 Answers1

0

You may simply union them:

var result = l1.Union(l2).ToList();
Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171