MemoryStream.ReadByte メソッド

定義

現在のストリームからバイトを読み取ります。

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

戻り値

Int32

Int32 にキャストしたバイト。ストリームの末尾に達した場合は -1。

例外

現在のストリーム インスタンスが閉じています。

このコード例は、MemoryStream クラスのために提供されている大規模な例の一部です。

// 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

注釈

このメソッドは、ReadByte をオーバーライドします。

読み取り操作が成功した場合、ストリーム内の現在の位置は 1 バイト進みます。 例外が発生した場合、ストリーム内の現在の位置は変更されません。

適用対象

こちらもご覧ください