MemoryStream.ReadByte 方法

定義

從目前的資料流讀取位元組。

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

傳回

轉型為 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

如果讀取作業成功,資料流程中的目前位置會由一個位元組進階。 如果發生例外狀況,資料流程中的目前位置不會變更。

適用於

另請參閱