Difference between System.Array.CopyTo() and System.Array.Clone()

By Santhosh N

This explains the difference between System.Array.CopyTo() and System.Array.Clone()

System.Array.CopyTo() performs deep copy of the array whereas  System.Array.Clone() performs shallow copy of the array.

This is what you find in many places which are not true.

Both the methods - System.Array.CopyTo() and System.Array.Clone()  perform shallow copy.

The real difference in them is - System.Array.CopyTo() require a destination array to be existed before and it must be capable to hold all the elements in the source array from the index that is specified to copy from the source array.
On the other hand, System.Array.Clone() method does not require the destination array to be existed as it creates a new one from scratch.

Related FAQs

This explains the difference between System.String and System.Text.StringBuilder
This explains about different type of arguments that can be passed to C# .Net methods.
This is how you can check if the given string is in numeric format or not in c#
Difference between System.Array.CopyTo() and System.Array.Clone()  (350 Views)
Create New Account