Hi...
Ques : What is the difference between the System.Array.CopyTo() and System.Array.Clone()?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jan 18, 2012, 10:53 PM
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.
please refer
http://msdn.microsoft.com/en-us/library/system.array.copy.aspx
http://msdn.microsoft.com/en-us/library/system.array.clone%28v=vs.85%29.aspx
hope this help.
Satyapriya NayakPosted Jan 18, 2012, 7:39 PM
The first one performs a deep copy of the array, the second one is shallow.
The CopyTo() method copies the elements into another existing array.The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.
Thanks