制作一个与另一个数据表具有相同列的新数据表 [英] Make a new DataTable with the same columns as another DataTable

查看:63
本文介绍了制作一个与另一个数据表具有相同列的新数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个与其他数据表具有相同列的新数据表。

I want to create a new DataTable that has the same columns as another DataTable.

当前,我执行以下操作:

Currently, I do the following:

DataTable myTable = new DataTable();
myTable = table.Copy();
myTable.Clear();

然后,根据需要将行导入到myTable中。

Then, I import rows into myTable as needed.

是否有更有效的方法?现在,如果表很大,那么行的行将有很多不必要的复制。

Is there a more efficient way of doing this? Right now if table is large, then there is a lot of unnecessary copying of rows going on.

谢谢。

推荐答案

尝试使用

myTable = table.Clone()

这篇关于制作一个与另一个数据表具有相同列的新数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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