MemoryStream.WriteByte(Byte) 方法

定義

寫入位元組至資料流目前位置。Writes a byte to the current stream at the current position.

public:
 override void WriteByte(System::Byte value);
public override void WriteByte (byte value);
override this.WriteByte : byte -> unit
Public Overrides Sub WriteByte (value As Byte)

參數

value
Byte

要寫入的位元組。The byte to write.

例外狀況

資料流不支援寫入。The stream does not support writing. 如需詳細資訊,請參閱 CanWriteFor additional information see CanWrite.

-或--or- 目前的位置在資料流結尾,並且無法修改容量。The current position is at the end of the stream, and the capacity cannot be modified.

目前的資料流已關閉。The current stream is closed.

範例

這個程式碼範例是針對MemoryStream類別提供之較大範例的一部分。This code example is part of a larger example provided for the MemoryStream class.

// Write the second string to the stream, byte by byte.
count = 0;
while ( count < secondString->Length )
{
   memStream->WriteByte( secondString[ count++ ] );
}
// Write the second string to the stream, byte by byte.
count = 0;
while(count < secondString.Length)
{
    memStream.WriteByte(secondString[count++]);
}
' Write the second string to the stream, byte by byte.
count = 0
While(count < secondString.Length)
    memStream.WriteByte(secondString(count))
    count += 1
End While

備註

這個方法覆寫 WriteByteThis method overrides WriteByte.

除了以 byte MemoryStream [] 參數所建立的之外,在MemoryStream展開的MemoryStream結尾處寫入作業。Except for a MemoryStream constructed with a byte[] parameter, write operations at the end of a MemoryStream expand the MemoryStream.

適用於

另請參閱