Gemstone Common Library
Show/Hide TOC

# ArrayExtensionsBlockCopy T Method

Returns a copy of the specified portion of the array array.

## Definition

Namespace: Gemstone.ArrayExtensions
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.180 -- Release Build+914ca9e6d1cce46b614eb7013eba0303271cf6d8
C#
View Source Request Example

    public static T[] BlockCopy<T>(
    	this T[] array,
    	int startIndex,
    	int length
    )

VB
View Source Request Example

    <ExtensionAttribute>
    Public Shared Function BlockCopy(Of T) (
    	array As T(),
    	startIndex As Integer,
    	length As Integer
    ) As T()

C++
View Source Request Example

    public:
    [ExtensionAttribute]
    generic<typename T>
    static array<T>^ BlockCopy(
    	array<T>^ array,
    	int startIndex,
    	int length
    )

JavaScript
View Source Request Example

    JavaScript does not support generic types or methods.

#### Parameters

array T
  Source array.
startIndex Int32
  Offset into array array.
length Int32
  Length of array array to copy at startIndex offset.

#### Type Parameters

T
  Type of array.

#### Return Value

T
An array of data copied from the specified portion of the source array.

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type T. 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).

## Remarks

Returned array will be extended as needed to make it the specified length, but it will never be less than the source array length - startIndex.

If an existing array of primitives is already available, using the BlockCopy(Array, Int32, Array, Int32, Int32) directly instead of this extension method may be optimal since this method always allocates a new return array. Unlike BlockCopy(Array, Int32, Array, Int32, Int32), however, this function also works with non-primitive types.

## Exceptions

ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for the source array -or- length is less than 0.

## See Also

#### Reference

ArrayExtensions Class
Gemstone.ArrayExtensions Namespace