To concat lists in C#, ue the Concat method.
The following is the list −
var list1 = new List<int>{12, 40};
var list2 = new List<int>{98, 122, 199, 230};Here is the Concat method −
var res = list1.Concat(list2);
The following is the example to work with Concat method −
Example
using System.Collections.Generic;
using System.Linq;
using System;
public class Demo {
public static void Main() {
// two lists
var list1 = new List<int>{12, 40};
var list2 = new List<int>{98, 122, 199, 230};
// concat
var res = list1.Concat(list2);
foreach(int i in res) {
Console.WriteLine(i);
}
}
}Output
12 40 98 122 199 230