Skip to content

StreamExtensions.ReadByteOrThrowAsync Method ​

Definition ​

Reads a single byte from the stream asynchronously, throwing EndOfStreamException if the end of the stream has been reached.

c#
public static ValueTask<Byte> ReadByteOrThrowAsync(this Stream stream, CancellationToken cancellationToken = null);

Parameters ​

NameTypeDescription
streamStream
cancellationTokenCancellationTokenA cancellation token.

Returns ​

ValueTask<Byte>

The byte read from the stream.