IBufferWriter<T>.GetSpan(Int32) Method

Definition

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

C#
public Span<T> GetSpan (int sizeHint = 0);

Parameters

sizeHint
Int32

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

Returns

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

Remarks

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

This method 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

Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1