C# 中的拼接方法
要拼接 C# 中的列表,请使用拼接方法。
以下是列表 −
var list1 = new List<int>{12, 40};
var list2 = new List<int>{98, 122, 199, 230};以下是拼接方法 −
var res = list1.Concat(list2);
以下是使用拼接方法的示例 −
示例
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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP