How create distinct copy of dataTable

I have a DataTable, let’s name it DT1 with some data
I create a new one (Assign : DT2 = new DataTable() )
I copy the data of DT1 in DT2 (Assign : DT2 = DT1)
My problem is when I remove some columns in DT2, there are also removed in DT1.
It seems my datatables are linked together, how could I create a separate copy of DT1?

1 Like

@alice the reason this happens is because the DataTable type is passed by reference instead of value.

You should be able to use Assign: DT2 = DT1.Copy to work around this


@JMP Thank you, it works!

1 Like