Edit

Share via


ArrayPoolExtensions.Resize<T> Method

Definition

Changes the number of elements of a rented one-dimensional array to the specified new size.

public static void Resize<T> (this System.Buffers.ArrayPool<T> pool, ref T[]? array, int newSize, bool clearArray = false);
static member Resize : System.Buffers.ArrayPool<'T> * T[] * int * bool -> unit
<Extension()>
Public Sub Resize(Of T) (pool As ArrayPool(Of T), ByRef array As T(), newSize As Integer, Optional clearArray As Boolean = false)

Type Parameters

T

The type of items into the target array to resize.

Parameters

pool
ArrayPool<T>

The target ArrayPool<T> instance to use to resize the array.

array
T[]

The rented T array to resize, or null to create a new array.

newSize
Int32

The size of the new array.

clearArray
Boolean

Indicates whether the contents of the array should be cleared before reuse.

Exceptions

Thrown when newSize is less than 0.

Remarks

When this method returns, the caller must not use any references to the old array anymore.

Applies to