top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

0 votes
408 views
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
posted Mar 31, 2017 by Madhavi Kumari

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
Clone - Method creates a shallow copy of an array.

A shallow copy of an Array copies only the elements of the Array, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to.

 CopyTo - The Copy static method of the Array class copies a section of an array to another array. 

The CopyTo method copies all the elements of an array to another one-dimension array. The code listed in Listing 9 copies contents of an integer array to an array of object types.

answer Mar 31, 2017 by Shweta Singh
...