Bewerken

Delen via


IBufferWriter<T>.GetMemory(Int32) Method

Definition

Returns a Memory<T> to write to that is at least the requested size (specified by sizeHint).

public Memory<T> GetMemory (int sizeHint = 0);
abstract member GetMemory : int -> Memory<'T>
Public Function GetMemory (Optional sizeHint As Integer = 0) As Memory(Of T)

Parameters

sizeHint
Int32

The minimum length of the returned Memory<T>. If 0, a non-empty buffer is returned.

Returns

A Memory<T> of at least the size sizeHint. If sizeHint is 0, returns a non-empty buffer.

Exceptions

The requested buffer size is not available.

Remarks

There is no guarantee that successive calls will return the same buffer or the same-sized buffer.

This must never return Span<T>.Empty, but it can throw if the requested buffer size is not available.

You must request a new buffer after calling Advance to continue writing more data; you cannot write to a previously acquired buffer.

Applies to