11.5. Copying Arrays

Copying one array to another comes in handy for programmers, and all it takes is a simple method call in both C# and Java. The Copy method is built into the System.Array object for C#, and the equivalent Java version, arrayCopy, is built into the Java System object.

Basically, C# has two versions of Array.Copy. These two functions can override each other based on the input parameters. Let's look at the two functions in detail.

The following function copies the specified number of elements from the specified source array to the specified destination array:

Array.Copy(sourceArray, destinationArray, length)

The Array.Copy function accepts three parameters: sourceArray of type System.Array, destinationArray of type System.Array ...

Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.