Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Reads at least a minimum number of bytes from the current stream and advances the position within the stream by the number of bytes read.
public int ReadAtLeast(Span<byte> buffer, int minimumBytes, bool throwOnEndOfStream = true);
member this.ReadAtLeast : Span<byte> * int * bool -> int
Public Function ReadAtLeast (buffer As Span(Of Byte), minimumBytes As Integer, Optional throwOnEndOfStream As Boolean = true) As Integer
A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current stream.
The minimum number of bytes to read into the buffer.
true
to throw an exception if the end of the stream is reached before reading minimumBytes
of bytes; false
to return less than minimumBytes
when the end of the stream is reached.
The default is true
.
The total number of bytes read into the buffer. This is guaranteed to be greater than or equal to minimumBytes
when throwOnEndOfStream
is true
. This will be less than minimumBytes
when the end of the stream is reached and throwOnEndOfStream
is false
. This can be less than the number of bytes allocated in the buffer if that many bytes are not currently available.
minimumBytes
is negative, or is greater than the length of buffer
.
throwOnEndOfStream
is true
and the end of the stream is reached before reading
minimumBytes
bytes of data.
When minimumBytes
is 0 (zero), this read operation will be completed without waiting for available data in the stream.
Product | Versions |
---|---|
.NET | 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in