Click or drag to resize
ArrayCopy Method (Array, Int32, Array, Int32, Int32)
Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. The length and the indexes are specified as 32-bit integers.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static void Copy(
	Array sourceArray,
	int sourceIndex,
	Array destinationArray,
	int destinationIndex,
	int length
)

Parameters

sourceArray
Type: SystemArray
The Array that contains the data to copy.
sourceIndex
Type: SystemInt32
A 32-bit integer that represents the index in the sourceArray at which copying begins.
destinationArray
Type: SystemArray
The Array that receives the data.
destinationIndex
Type: SystemInt32
A 32-bit integer that represents the index in the destinationArray at which storing begins.
length
Type: SystemInt32
A 32-bit integer that represents the number of elements to copy.
Exceptions
ExceptionCondition
ArgumentNullExceptionsourceArray is null.-or-destinationArray is null.
RankExceptionsourceArray and destinationArray have different ranks.
ArrayTypeMismatchExceptionsourceArray and destinationArray are of incompatible types.
InvalidCastExceptionAt least one element in sourceArray cannot be cast to the type of destinationArray.
ArgumentOutOfRangeExceptionsourceIndex is less than the lower bound of the first dimension of sourceArray.-or-destinationIndex is less than the lower bound of the first dimension of destinationArray.-or-length is less than zero.
ArgumentExceptionlength is greater than the number of elements from sourceIndex to the end of sourceArray.-or-length is greater than the number of elements from destinationIndex to the end of destinationArray.
See Also