Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

PipeWriter.GetMemory(Int32) Method

Definition

Namespace:
System.IO.Pipelines
Assembly:
System.IO.Pipelines.dll
Package:
System.IO.Pipelines v11.0.0-preview.5.26302.115
Source:
PipeWriter.cs
Source:
PipeWriter.cs
Source:
PipeWriter.cs
Source:
PipeWriter.cs
Source:
PipeWriter.cs
Source:
PipeWriter.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Returns a Memory<T> to write to that is at least the requested size, as specified by the sizeHint parameter.

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

Parameters

sizeHint
Int32

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

Returns

A memory buffer of at least sizeHint bytes. If sizeHint is 0, returns a non-empty buffer of arbitrary size.

Implements

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 method never returns Memory<T>.Empty, but it throws an OutOfMemoryException 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


Feedback

Was this page helpful?