Clone vs CopyTo Methods in C#

Hi Programmers, welcome new article of ozanecare. this article i’m going to explain all important differences between CopyTo vs Clone methods in c# programming language.Let’s see. 1.CopyTo method copies the elements into another existing array but Clone method returns a new array containing all the elements in the old array. 2.CopyTo method Require index parameter but clone method doesnt require index parameter. 3.CopyTo method must have two parameter but clone method doesn’t require any parameters. 4.Array.CopyTo requires a destination array but Array.Clone doesn’t require a target/destination array.

Above Code Explanation: source.CopyTo(target,index) or st1.CopyTo(str2,2) so ,it starts copy elements from 2 index so zero and one index it stores null values. since st2 array size 10 then it stores rest place null.the new values of st2 are null,null, “Pocco”, “IPhone”, “Samsung”, ,Sony”,null,null,null,null so st2[2] = Pocco.
and about clone method that i already discussed last blog.

Happy Coding…Thanks.

Post Author: adama