首页 > 代码库 > DataRow[]转换DataTable

DataRow[]转换DataTable

public 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.Rows.Add(row);  // DataRow添加到DataTable
        return tmp;
    }


DataRow[]转换DataTable