If this is a list, you can also use AddRange .
var listB = new List<int>{3, 4, 5}; var listA = new List<int>{1, 2, 3, 4, 5}; listA.AddRange(listB);
If you need a new list (and exclude duplicate), you can use union
var listB = new List<int>{3, 4, 5}; var listA = new List<int>{1, 2, 3, 4, 5}; var listFinal = listA.Union(listB);
If you need a new list (and specify a duplicate), you can use concat
var listB = new List<int>{3, 4, 5}; var listA = new List<int>{1, 2, 3, 4, 5}; var listFinal = listA.Concat(listB);
If you need common elements, you can use Intersect .
var listB = new list {3, 4, 5};
var listA = new List {1, 2, 3, 4};
var listFinal = listA.Intersect (listB); // 3.4
Tilak Nov 22 '12 at 4:01 2012-11-22 04:01
source share