以数据行数组转换为数据表的简单方法 [英] Simple way to convert datarow array to datatable

查看:150
本文介绍了以数据行数组转换为数据表的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要一个的DataRow 数组转换成数据表 ...什么是做到这一点最简单的方法?

I want to convert a DataRow array into DataTable ... What is the simplest way to do this?

推荐答案

为什么不通过你的DataRow数组进行迭代,并添加(使用DataRow.ImportRow,如果需要的话,得到的DataRow的副本),是这样的:

Why not iterate through your DataRow array and add (using DataRow.ImportRow, if necessary, to get a copy of the DataRow), something like:

foreach (DataRow row in rowArray) {
   dataTable.ImportRow(row);
}

请确保您的表具有相同的架构作为您的DataRow数组数据行。

Make sure your dataTable has the same schema as the DataRows in your DataRow array.

这篇关于以数据行数组转换为数据表的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆