Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Array.Copy and Array.CopyTo?

Tags:

arrays

c#

.net

Is there any difference between Array.Copy and CopyTo? Are they just overloaded?

like image 674
Udana Avatar asked Nov 28 '22 12:11

Udana


2 Answers

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

Array.Copy(arraySrc, arrayDest, arraySrc.length);
arraySrc.CopyTo(arrayDest, startingIndex);
like image 155
popester Avatar answered Dec 15 '22 04:12

popester


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

like image 29
shahkalpesh Avatar answered Dec 15 '22 02:12

shahkalpesh