difference between
-
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
-
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
-
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object. Regards, Bhupi Bhai.
-
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
-
The first one (System.Array.CopyTo()) performs a deep copy of the array, the second one(System.Array.Clone()) is shallow copy of the array:) Mohan
Mohan, Neither of the two perform deep copy. Both CopyTo and Clone perform Shallow copy. Regards, Bhupi Bhai.
-
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
Visit http://www.thescripts.com/forum/thread269691.html[^] One para from the same. A copyto makes a copy of the values in/from a one dimensional array (where the type of the sender and the receiver has to be the same and the receiver completly exist already). A clone copies the references, therefore using the references in the clone will have the same effect on the referenced objects as using the original array. Although you can have at a certain moment in a clone more references than in the original or/and visa versa. A deepcopy you have to make yourself. The system does not know what objects you have added to by instance your arraylist. (It can be by instance a thousand times deep arraylist).
Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET