Linq – combine items of two lists

linq

I want to combine items of two string list but do not want repeated items

List<string> l1 = new List<string>() { "A", "B", "C", "D"};
List<string> l2 = new List<string>() { "B", "E", "G", "D"};

Result: A, B, C, D, E, G

How can i achieve this?

Best Solution

Use the Union and Distinct operators:

var newList = l1.Union(l2).Distinct().ToList();