Επεξεργασία

Κοινή χρήση μέσω


MemoryStream.ReadByte Method

Definition

Reads a byte from the current stream.

public:
 override int ReadByte();
public override int ReadByte ();
override this.ReadByte : unit -> int
Public Overrides Function ReadByte () As Integer

Returns

The byte cast to a Int32, or -1 if the end of the stream has been reached.

Exceptions

The current stream instance is closed.

Examples

This code example is part of a larger example provided for the MemoryStream class.

// Read the remaining bytes, byte by byte.
while ( count < memStream->Length )
{
   byteArray[ count++ ] = Convert::ToByte( memStream->ReadByte() );
}
// Read the remaining bytes, byte by byte.
while(count < memStream.Length)
{
    byteArray[count++] = (byte)memStream.ReadByte();
}
' Read the remaining Bytes, Byte by Byte.
While(count < memStream.Length)
    byteArray(count) = _
        Convert.ToByte(memStream.ReadByte())
    count += 1
End While

Remarks

This method overrides ReadByte.

If the read operation is successful, the current position within the stream is advanced by one byte. If an exception occurs, the current position within the stream is unchanged.

Applies to

See also