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

Total Post:154

Points:1086
C#  .NET 
C#
 1073  View(s)
Ratings:
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.
  1. Post:135

    Points:949
    Re: difference between System.Array.CopyTo() and System.Array.Clone()

    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.


      Modified On Apr-11-2018 01:15:54 AM

Answer