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?
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
andDistinct
operators: