Concat
The Concat
(short for concatenate) method can be used to combine two lists together to make one big list. However, both lists need to be of the same type, and it will ignore any duplicates. In other words, duplicates will occur if they appear in the both lists.
Basic example
In this example, we have two lists. set1
have numbers from 1 through to 10. set2
contains even numbers from 2 to 10.
Using the .Concat
method, the result will combine these two lists. Take note that the list of even numbers is simply appended to the end of the first list.
If you are looking to combine two lists together and eliminate the duplicates, you can use Union or GroupBy
Live example: https://dotnetfiddle.net/hVwwOc
var set1 = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var set2 = new[] { 2, 4, 6, 8, 10 };
var result = set1.Concat(set2);
// output: 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10