Edit

Share via


StreamExtensions.Read Method

Definition

Overloads

Read(Stream, Span<Byte>)
Obsolete.

Reads a sequence of bytes from a given Stream instance.

Read<T>(Stream)

Reads a value of a specified type from a source Stream instance.

Read(Stream, Span<Byte>)

Source:
StreamExtensions.cs
Source:
StreamExtensions.cs

Caution

This API is only available for binary compatibility, but Stream.Read should be used instead.

Reads a sequence of bytes from a given Stream instance.

[System.Obsolete("This API is only available for binary compatibility, but Stream.Read should be used instead.")]
public static int Read(this System.IO.Stream stream, Span<byte> buffer);
public static int Read(this System.IO.Stream stream, Span<byte> buffer);
[<System.Obsolete("This API is only available for binary compatibility, but Stream.Read should be used instead.")>]
static member Read : System.IO.Stream * Span<byte> -> int
static member Read : System.IO.Stream * Span<byte> -> int
<Extension()>
Public Function Read (stream As Stream, buffer As Span(Of Byte)) As Integer

Parameters

stream
Stream

The source Stream to read data from.

buffer
Span<Byte>

The target Span<T> to write data to.

Returns

The number of bytes that have been read.

Attributes

Applies to

Read<T>(Stream)

Source:
StreamExtensions.cs
Source:
StreamExtensions.cs

Reads a value of a specified type from a source Stream instance.

public static T Read<T>(this System.IO.Stream stream) where T : struct;
static member Read : System.IO.Stream -> 'T (requires 'T : struct)
<Extension()>
Public Function Read(Of T As Structure) (stream As Stream) As T

Type Parameters

T

The type of value to read.

Parameters

stream
Stream

The source Stream instance to read from.

Returns

T

The T value read from stream.

Exceptions

Thrown if stream reaches the end.

Thrown if stream reaches the end.

Applies to