更新时间:2023-12-01 15:09:04
这是因为dtcopy和dt都引用相同的对象.
使用 DataTable.Copy方法 [
This is because both dtcopy and dt are referencing the same object.
Use DataTable.Copy Method[^] to copy from one datatable to another.
Instead of
dtcopy=dt;
使用
Use
dtcopy = dt.Copy();
复制数据表.
如果只需要数据表的结构而不是数据,则可以使用 DataTable.Clone方法 [^ ]
to copy the data table.
If you want only the structure of datatable and not the data you can use DataTable.Clone Method[^]