Copy and Clone
Clone:-
It only copies structure, does not copy data. Creates another reference (Pointer) to the same location.
Example 1-
dt=ds.Table[0].clone(); //will create only the structure of table not data.
Example 2-
private void GetClone(DataTable table)
{
// Get a clone of the original DataTable.
DataTable cloneTable;
cloneTable = table.Clone();
}
Copy:-
Copies both Structure and data. Creates two different references to two different Address Spaces.
copy is deep copy. copy the structure and data of the object.
Example
DataTable dt=new DataTable();
dt=ds.Tables[0].copy(); // Will copy all the data and structure to dt table
Dataset .Copy: - It copies both structure and data.
Dataset .Clone: - It only copies structure, does not copy data.
No comments:
Post a Comment