MemoryMarshal.CreateFromPinnedArray<T>(T[], Int32, Int32) Method

Definition

Creates a new memory buffer over the portion of the pre-pinned target array beginning at the start index and consisting of length items.

public:
generic <typename T>
 static Memory<T> CreateFromPinnedArray(cli::array <T> ^ array, int start, int length);
public static Memory<T> CreateFromPinnedArray<T> (T[]? array, int start, int length);
public static Memory<T> CreateFromPinnedArray<T> (T[] array, int start, int length);
static member CreateFromPinnedArray : 'T[] * int * int -> Memory<'T>
Public Shared Function CreateFromPinnedArray(Of T) (array As T(), start As Integer, length As Integer) As Memory(Of T)

Type Parameters

T

The type of the array.

Parameters

array
T[]

The pre-pinned source array.

start
Int32

The index of array at which to begin the memory block.

length
Int32

The number of items to include in the memory block.

Returns

A block of memory over the specified elements of array. If array is null, or if start and length are 0, the method returns a Memory<T> instance of Length zero.

Exceptions

array is covariant, and the type of array is not exactly T[].

The start or the end index is not in the range of 0 to Length.

Remarks

The array must already be pinned before this method is called, and that array must not be unpinned while the Memory<T> buffer that it returns is still in use. Calling this method on an unpinned array could result in memory corruption.

Applies to