C#DataRow转换为DataTable

C#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;
}

二、

.CopyToDataTable<DataRow>()

 

posted @ 2022-05-19 15:59  大木瓜  阅读(703)  评论(0)    收藏  举报