Edit

Share via


MemoryOwner<T>.DangerousGetArray Method

Definition

Gets an ArraySegment<T> instance wrapping the underlying T array in use.

public ArraySegment<T> DangerousGetArray ();
member this.DangerousGetArray : unit -> ArraySegment<'T>
Public Function DangerousGetArray () As ArraySegment(Of T)

Returns

An ArraySegment<T> instance wrapping the underlying T array in use.

Exceptions

Thrown when the buffer in use has already been disposed.

Remarks

This method is meant to be used when working with APIs that only accept an array as input, and should be used with caution. In particular, the returned array is rented from an array pool, and it is responsibility of the caller to ensure that it's not used after the current MemoryOwner<T> instance is disposed. Doing so is considered undefined behavior, as the same array might be in use within another MemoryOwner<T> instance.

Applies to