Skip to content

M_CodeJam_Collections_ArrayExtensions_ConstrainedCopy

Andrew Koryavchenko edited this page Jun 17, 2018 · 7 revisions

ArrayExtensions.ConstrainedCopy Method

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. Guarantees that all changes are undone if the copy does not succeed completely.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static void ConstrainedCopy(
	this Array sourceArray,
	int sourceIndex,
	Array destinationArray,
	int destinationIndex,
	int length
)

VB

<ExtensionAttribute>
Public Shared Sub ConstrainedCopy ( 
	sourceArray As Array,
	sourceIndex As Integer,
	destinationArray As Array,
	destinationIndex As Integer,
	length As Integer
)

F#

[<ExtensionAttribute>]
static member ConstrainedCopy : 
        sourceArray : Array * 
        sourceIndex : int * 
        destinationArray : Array * 
        destinationIndex : int * 
        length : int -> unit 

Parameters

 

sourceArray
Type: System.Array
The Array that contains the data to copy.
sourceIndex
Type: System.Int32
A 32-bit integer that represents the index in the sourceArray at which copying begins.
destinationArray
Type: System.Array
The Array that receives the data.
destinationIndex
Type: System.Int32
A 32-bit integer that represents the index in the destinationArray at which storing begins.
length
Type: System.Int32
A 32-bit integer that represents the number of elements to copy.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Array. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

 

Exception Condition
ArgumentNullException sourceArray is null.-or-destinationArray is null.
RankException sourceArray and destinationArray have different ranks.
ArrayTypeMismatchException The sourceArray type is neither the same as nor derived from the destinationArray type.
InvalidCastException At least one element in sourceArray cannot be cast to the type of destinationArray.
ArgumentOutOfRangeException sourceIndex 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.
ArgumentException length 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

Reference

ArrayExtensions Class
CodeJam.Collections Namespace

Clone this wiki locally