Edit

Share via


ReadOnlySequenceExtensions.AsStream(ReadOnlySequence<Byte>) Method

Definition

Returns a Stream wrapping the contents of the given Memory<T> of Byte instance.

public static System.IO.Stream AsStream(this System.Buffers.ReadOnlySequence<byte> sequence);
static member AsStream : System.Buffers.ReadOnlySequence<byte> -> System.IO.Stream
<Extension()>
Public Function AsStream (sequence As ReadOnlySequence(Of Byte)) As Stream

Parameters

sequence
ReadOnlySequence<Byte>

The input ReadOnlySequence<T> of Byte instance.

Returns

A Stream wrapping the data within sequence.

Remarks

Since this method only receives a ReadOnlySequence<T> instance, which does not track the lifetime of its underlying buffer, it is responsibility of the caller to manage that. In particular, the caller must ensure that the target buffer is not disposed as long as the returned Stream is in use, to avoid unexpected issues.

Applies to