BinaryReader.Read Method (Byte(), Int32, Int32)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Reads count bytes from the stream with index as the starting point in the byte array.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Overridable Function Read ( _ buffer As Byte(), _ index As Integer, _ count As Integer _ ) As Integer
Parameters
- buffer
- Type:
System.Byte
()
The buffer to read data into.
- index
- Type: System.Int32
The starting point in the buffer at which to begin reading into the buffer.
- count
- Type: System.Int32
The number of characters to read.
Return Value
Type: System.Int32The number of characters read into buffer. This might be less than the number of bytes requested if that many bytes are not available, or it might be zero if the end of the stream is reached.
| Exception | Condition |
|---|---|
| ArgumentException | The buffer length minus index is less than count. -or- The number of decoded characters to read is greater than count. This can happen if a Unicode decoder returns fallback characters or a surrogate pair. |
| ArgumentNullException | buffer is Nothing. |
| ArgumentOutOfRangeException | index or count is negative. |
| ObjectDisposedException | The stream is closed. |
| IOException | An I/O error occurs. |
BinaryReader does not restore the file position after an unsuccessful read operation.