C#에서 목록을 연결하려면 Concat 메서드를 사용하세요.
다음은 목록입니다 -
var list1 = new List<int>{12, 40};
var list2 = new List<int>{98, 122, 199, 230}; 다음은 Concat 방법입니다 -
var res = list1.Concat(list2);
다음은 Concat 방식으로 작업하는 예입니다 -
예시
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);
}
}
} 출력
12 40 98 122 199 230