将table2中的首行数据添加到table1的首行
private DataTable GetDataTable(DataTable table1 ,DataTable table2) { DataTable result = null; if (table1.Rows.Count>0&&table1!=null) { result = table1; if (table2 != null&&table2.Rows.Count>0) { DataRow row = null; row = table1.NewRow(); for (int i = 0; i < table2.Columns.Count; i++) { if (result.Columns.Contains(table2.Columns[i].ColumnName)) { var temp = table2.Rows[0][table2.Columns[i].ColumnName]; row[table2.Columns[i].ColumnName] = table2.Rows[0][table2.Columns[i].ColumnName]; } } result.Rows.InsertAt(row, 0); } } return result; }