//数组拼接 var intArray_1 = new int[] { 1, 2, 3 }; var intArray_2 = new int[] { 4, 5, 6 }; var result = intArray_1.Concat(intArray_2); foreach (var item in result) { Console.WriteLine(item); }
//datatable拼接 //创建表头 DataTable dt1 = new DataTable(); dt1.Columns.Add(new DataColumn("姓名",typeof(string))); dt1.Columns.Add(new DataColumn("年龄", typeof(string))); dt1.Columns.Add(new DataColumn("班级", typeof(string))); //添加一行数据 DataRow dr = dt1.NewRow(); dr["姓名"] = "小明"; dr["年龄"] = "18"; dr["班级"] = "三班"; dt1.Rows.Add(dr); //克隆一个dt var newDataTable = dt1.Clone(); //添加一行数据 newDataTable.Rows.Add(dr); //合并两个datatable--用Merge()这个方法即可 dt1.Merge(newDataTable);