Hi...
Ques : What is the difference between the System.Array.CopyTo() and System.Array.Clone()?
What is the difference between the System.Array.CopyTo()
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 18, 2012, 2:39 PM EST
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
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 18, 2012, 5:53 PM EST
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.