Is it correct to use Array.CopyTo to copy elements or should a for-loop always be used?

Posted by Arc on Stack Overflow See other posts from Stack Overflow or by Arc
Published on 2010-06-11T20:18:44Z Indexed on 2010/06/11 20:22 UTC
Read the original article Hit count: 186

Filed under:
|
|
|
|

It's easier to write

intArray1.CopyTo( intArray2, 0 )

than the for-loop equivalent, but System.Array does not provide any generic Copy/CopyTo methods.

Is it better to write the for-loop? Or is using Copy/CopyTo compiled or JIT'd efficiently enough?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET