Read Method
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public MustOverride Function Read ( _
buffer As Byte(), _
offset As Integer, _
count As Integer _
) As Integer
public abstract int Read(
byte[] buffer,
int offset,
int count
)
public:
virtual int Read(
array<unsigned char>^ buffer,
int offset,
int count
) abstract
abstract Read :
buffer:byte[] *
offset:int *
count:int -> int
public abstract function Read(
buffer : byte[],
offset : int,
count : int
) : int
Parameters
- buffer
Type: array<System. . :: . .Byte> [] () [] []
An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
- offset
Type: System. . :: . .Int32
The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
- count
Type: System. . :: . .Int32
The maximum number of bytes to be read from the current stream.
Return Value
Type: System. . :: . .Int32
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
Remarks
Use the CanRead property to determine whether the current instance supports reading. Use the ReadAsync method to read asynchronously from the current stream.
Implementations of this method read a maximum of count bytes from the current stream and store them in buffer beginning at offset. The current position within the stream is advanced by the number of bytes read; however, if an exception occurs, the current position within the stream remains unchanged. Implementations return the number of bytes read. The implementation will block until at least one byte of data can be read, in the event that no data is available. Read returns 0 only when there is no more data in the stream and no more is expected (such as a closed socket or end of file). An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.