DIFFERENCE BETWEEN SYSTEM.ARRAY.COPYTO() AND SYSTEM.ARRAY.CLONE()

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C#  .NET 
C#
 742  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. Anupam Mishra

    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.


Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!