[Reserved] C # quickly create the same architecture by the Clone method of DataTable

During operation Datatable data variables in C #, if the need to clone the structure of the current DataTable variables, including all DataTable schema and constraints and other information, can use the Clone method of the DataTable achieved signature Clone method for Virtual DataTable Clone () without any parameters. Clone () method and compared with the Copy method, Clone cloning method does not copy data information in the DataTable, the Copy method to copy the configuration information in addition to further copy the data in the DataTable.

DataTable.Clone Method: Cloning DataTable structure, including all DataTable schema and constraints.

DataTable.Copy Method: copying the data structure and DataTable.

Firstly, we have the Demo Datatable variable dataDt configuration information contained in the table 3, respectively, Name, Id, Memo. If configuration information needs to be copied to another quickly dataDt DataTable variable newDT may be used Clone method, embodied as follows:

 var newDt = dataDt.Clone();

The above statement used in the Clone () method, even if there are many rows of data, will not be copied to newDt variable dataDt table, if you need to copy the data lines together to newDt, then you should use the Copy method instead of the Clone method.

Copy can refer to this article: C # quickly copied by the Copy method DataTable object .

 

Note: The text reproduced from personal bloggers station IT technology small fun house , the original link for the C # framework created by the same method Clone Technology Fast DataTable_IT little fun house .

Bloggers personal technology exchange group: 960 640 092, blogger micro-channel public numbers are as follows:

Guess you like

Origin www.cnblogs.com/xu-yi/p/11246468.html