c# datarow[] 转换成 datatable

#region DataRow[]转DataTable
private DataTable ToDataTable(DataRow[] rows)
{
if (rows == null || rows.Length == 0) return null;
DataTable tmp = rows[0].Table.Clone(); // 复制DataRow的表结构
foreach (DataRow row in rows)
{

tmp.ImportRow(row); // 将DataRow添加到DataTable中
}
return tmp;
}
#endregion

猜你喜欢

转载自www.cnblogs.com/aijiao/p/9723284.html