Sapna Malik
What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?
By Sapna Malik in C# on Oct 09 2009
  • Munesh Sharma
    Jul, 2015 22

    Array.Clone() method makes a clone of the original array. It returns an exact length array. Array.Clone() method does not require the destination array to be existed as it creates a new one from scratch Array.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. 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.

    • 0
  • Umar Ali
    Sep, 2012 1

    Please refer to the following URL to know the differences between System.Array.CopyTo() and System.Array.Clone(),http://onlydifferencefaqs.blogspot.in/2012/08/difference-between-clone-and-copyto.html

    • 0
  • Maggi
    Oct, 2010 4

    String is immutable in nature i.e. every time you need to make a change to the string a new object will be created and then the change will be done and reflected.

    When there is a requirement of frequent repeated changes in string STRING BUILDER is used instead of string.

    However, string is more powerful in terms of methods than the string builder.

    • 0
  • santhana krishnan
    Dec, 2009 15

    System.Array.copyto() will perform a deep copy of array while system.array.Clone(0 will perform shalow copy of the array.Shalow copy will simply copy the elements of the array where as an Deep copy will copy the elements as well as any referenced elements present in the array.

    • 0
  • Raghvendr Singh
    Dec, 2009 7

    Array.CopyTo() copies all contents of original array to another array by specied index of original array while Clone creates a shallow copy. Array.CopyTo() copies Data as well as structure while Clone copies data only.

    • 0
  • Asheej TK
    Nov, 2009 10

    Still need more detailed info refer below link

    http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=28509

    • 0
  • SAURABH KUMAR
    Nov, 2009 10

    System.Array.CopyTo copies all the contents of the existing array while System.Array.Clone creates a shallow model similar to the existing array.

    • 0
  • Pradeep
    Oct, 2009 16

    The System.Arry.Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The System.Arry.CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object. 

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS