What is the difference between System.Array.CopyTo() and System.Array.Clone()?

 Posted by Manimaddu on 8/11/2014 | Category: C# Interview questions | Views: 36116 | Points: 40
Answer:

Both the method are used for copy the data. But the difference is System.Array.CopyTo() method performs deep copy and System.Array.Clone() method performs shallow copy.
Here deep copy means it will create new instance of each element object where as shallow copy contains reference of same object.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Shadyyehia on: 5/17/2015 | Points: 10
Both of them is making a Shallow Copy , but CopyTo is copying to existing array . Clone creates a new one.

Login to post response