luni, 25 august 2014

Difference between Clone() and Copy() method C#

Clone and Copy

Clone will copy the structure of a data 
Copy will copy the complete structure and data.

Example:
Difference between Clone() and Copy() method

 string[] arr1 = { "a""b""c" }; 
 string[] arr2 = arr1; //copy
 string[] arr3 = (string[])arr1.Clone();
 arr2[0] = "x";
 MessageBox.Show(arr1[0] + "," + arr2[0] + "," + arr3[0]);

Niciun comentariu:

Trimiteți un comentariu