Click here to Skip to main content
15,876,993 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here DTLocal1 and DTLocal1 are two different datatable. Here are used Clone method and ImportRow method. I want to know why we use Clone and ImportRow in the following code snippet. Please explain


C#
DataTable DTLocal1 = DTLocal.Clone();
if (DTLocal.Rows.Count != 0)
{
    for (int i = 0; i < DTLocal.Rows.Count; i++)
    {
        DTLocal1.ImportRow(DTLocal.Rows[i]);
    }
}


[edit]Code block added[/edit]
Posted
Updated 15-Apr-13 0:50am
v2

1 solution

Clone - clones the structure of DTLocal to DTLocal1. No data values are copied.

http://msdn.microsoft.com/en-us/library/system.data.datatable.clone.aspx[^]

ImportRow copies the row with data values to DTLocal1.

http://msdn.microsoft.com/en-us/library/system.data.datatable.importrow.aspx[^]
 
Share this answer
 
Comments
Sumon562 15-Apr-13 22:48pm    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900