使用与另一个 DataTable 相同的列创建一个新的 DataTable [英] Make a new DataTable with the same columns as another DataTable
本文介绍了使用与另一个 DataTable 相同的列创建一个新的 DataTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个与另一个 DataTable 具有相同列的新 DataTable.
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()
这篇关于使用与另一个 DataTable 相同的列创建一个新的 DataTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文