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
2009-10-22 05:03:35
Thank you very much
Udana
2009-10-22 05:09:02
+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
2009-10-22 05:03:50
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
2009-10-22 05:05:25
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 theSystem.Collections.ICollection
interface. If implementingSystem.Collections.ICollection
is not explicitly required, useCopy
to avoid an extra indirection.
husayt
2009-11-03 14:58:54