Editar

Compartilhar via


MemoryExtensions.AsStream(Memory<Byte>) Method

Definition

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

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

Parameters

memory
Memory<Byte>

The input Memory<T> of Byte instance.

Returns

A Stream wrapping the data within memory.

Exceptions

Thrown when memory has an invalid data store.

Remarks

Since this method only receives a Memory<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