What is difference between clone and copyTo method?

Posted by Kumarkrishna184 under C# on 3/23/2018 | Points: 10 | Views : 787 | Status : [Member] | Replies : 2
What is difference between clone and copyTo method?

Thanks and Regards,
Krishna Kumar



Responses

Posted by: Vedikaledange on: 1/4/2019 [Member] Starter | Points: 25

Up
0
Down
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 would create a new instance of each element's object, resulting in a different, yet identacle object.

DOT NET

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sherin on: 3/12/2019 [Member] Starter | Points: 25

Up
0
Down
CopyTo() copies the elements into an existing array while Clone() copies all the elements of original array into a new array.

.NET Developer
iFour Technolab Pvt Ltd
http://www.ifourtechnolab.com

Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response