Given I have two list like the following:
var listA = new List<string> { "test1", "test2", "test3" };
var listB = new List<string> { "test2", "test3", "test4" };
I want a third list with:
var listC = new List<string> { "test1", "test2", "test3", "test4"}
Is there a way to get this?
In Excel, there is no built-in function can quickly merge sheets and remove duplicates, you just can copy and paste the sheet contents one by one then apply Remove Duplicates function to remove the duplicates.
Try the Union extension method.
var result = listA.Union(listB).ToList();
Union produces the set union of two sequences by using the default equality comparer so the result contains only distinct values from both lists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With