Home > DeveloperSection > Forums > difference between System.Array.CopyTo() and System.Array.Clone()
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    February-01-2016 10:29 PM

 C# C#  .NET 
Ratings:


 1 Reply(s)
 394  View(s)
Rate this:
Hi all,
I want to use a shallow copy of my array but i am confuse between System.Array.CopyTo() and System.Array.Clone().
So, Please give me a solution.
Thank you.


Anupam Mishra

Total Post:135

Points:949
Posted on    February-01-2016 10:43 PM

Both CopyTo() and Clone() make shallow copy. Clone() method makes a clone of the original array. It returns an exact length array.

On the other hand, CopyTo() copies the elements from the original array to the destination array starting at the specified destination array index. Note that, this adds elements to an already existing array.



Don't want to miss updates? Please click the below button!

Follow MindStick