tags:

views:

329

answers:

4

Is there any difference between Array.Copy ,CopyTo? Are they Just Overloaded ?

+4  A: 

Look at it carefully. Copy is a static method whereas CopyTo is an instance method.

shahkalpesh
Thank you very much
Udana
+4  A: 

Same functionality, different calling conventions. Copy is a static method, while CopyTo isn't. i.e.:

Array.Copy(arrayDest, arraySrc, arraySrc.length);
arraySrc.CopyTo(arrayDest, arraySrc.length);
popester
Thank you friend
Udana
A: 

Functionally, I don't know if there is anything different between the two other than the CopyTo method will copy all elements of the array and Copy will allow you to specify a range of elements to copy

lomaxx
Thank you very much
Udana
A: 

But they are not only conventionwise different, there is a key functional difference.

Here is an excerpt from MSDN:

This method (Array.CopyTo) supports the System.Collections.ICollection interface. If implementing System.Collections.ICollection is not explicitly required, use Copy to avoid an extra indirection.

husayt