Writes a byte to the current position in the stream.
If the stream is closed or not writable, an exception will be thrown.
[Visual Basic] Overridable Public Sub WriteByte( _ ByVal value As Byte _ ) [C#] public virtual void WriteByte( byte value ); [C++] public: virtual void WriteByte( unsigned char value ); [JScript] public function WriteByte( value : Byte );
Exception Type | Condition |
---|---|
IOException | The stream is closed. |
NotSupportedException | The stream does not support writing. |
While correct, the implementation on Stream creates a new one byte long array then calls Write(byte[], int, int). Any stream with an internal buffer should override this method and provide a much more efficient version that reads their buffer directly, avoiding the extra array allocation on every call.