asp.net.ph

Array.Copy Method ( Array, Array, Int32 )

System Namespace   Array Class


Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element.

[ VB ]
<Serializable>
Overloads Public 
Shared Sub Copy ( _
   ByVal sourceArray As Array, _
   ByVal destinationArray As Array, _
   ByVal length As Integer _
)

[ C# ]
[Serializable]
public static void Copy (
   Array sourceArray,
   Array destinationArray,
   int length
);

[ C++ ]
[Serializable]
public: static void Copy (
   Array* sourceArray,
   Array* destinationArray,
   int length
);

[JScript ]
public Serializable
static function Copy (
   sourceArray : Array,
   destinationArray : Array,
   length : int
);

Parameters

sourceArray
The Array that contains the data to copy.
destinationArray
The Array that receives the data.
length
The number of elements to copy.

Exceptions


Exception Type Condition
ArgumentNullException sourceArray is a null reference ( Nothing in Visual Basic ).

-or-

destinationArray is a null reference ( Nothing ).

RankException sourceArray and destinationArray have different ranks.
ArrayTypeMismatchException sourceArray and destinationArray are of incompatible types.
InvalidCastException At least one element in sourceArray cannot be cast to the type of destinationArray.
ArgumentOutOfRangeException length is less than zero.
ArgumentException length is greater than the number of elements in sourceArray.

-or-

length is greater than the number of elements in destinationArray.


Remarks

The sourceArray and destinationArray parameters must have the same number of dimensions.

When copying between multidimensional arrays, the array behaves like a long one-dimensional array, where the rows ( or columns ) are conceptually laid end to end. For example, if an array has three rows ( or columns ) with four elements each, copying six elements from the beginning of the array would copy all four elements of the first row ( or column ) and the first two elements of the second row ( or column ).

If sourceArray and destinationArray overlap, this method behaves as if the original values of sourceArray were preserved in a temporary location before destinationArray is overwritten.

[ C++ ] This method is equivalent to the standard C/C++ function memmove, not memcpy.

The arrays can be reference-type arrays or value-type arrays. Type downcasting is performed, as required.

An ArrayTypeMismatchException is thrown if the arrays are of incompatible types. Type compatibility is defined as follows:

If every element in sourceArray requires a downcast ( for example, from a base class to a derived class or from an interface to an object ) and one or more elements cannot be cast to the corresponding type in destinationArray, an InvalidCastException is thrown.

If this method throws an exception while copying, the state of destinationArray is undefined.

See Also

Array Members   Array.Copy Overload List Skip Navigation Links


Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note