Samir Bhogayta
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
By Samir Bhogayta in C# on Jun 25 2016
  • Ayappan Alagesan
    Feb, 2017 10

    System.Array.CopyTo() is used when only we have source and destination array.This works in existing array. System.Array.Clone() is used when only we have source and not destination array.This create a new duplicate of array.

    • 0
  • Samir Bhogayta
    Jun, 2016 25

    The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The 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