System.Data.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;
}

 
分类: c
posted @ 2020-12-09 20:00  心中Where_True循环  阅读(504)  评论(0编辑  收藏  举报