Stream.WriteByte(Byte) Método
Definição
Grava um byte na posição atual no fluxo e avança a posição dentro no fluxo em um byte.Writes a byte to the current position in the stream and advances the position within the stream by one byte.
public:
virtual void WriteByte(System::Byte value);
public virtual void WriteByte (byte value);
abstract member WriteByte : byte -> unit
override this.WriteByte : byte -> unit
Public Overridable Sub WriteByte (value As Byte)
Parâmetros
- value
- Byte
O byte a ser gravado no fluxo.The byte to write to the stream.
Exceções
Ocorre um erro de E/S.An I/O error occurs.
O fluxo não dá suporte à gravação ou o fluxo já foi fechado.The stream does not support writing, or the stream is already closed.
Foram chamados métodos depois que o fluxo foi fechado.Methods were called after the stream was closed.
Comentários
Use a CanWrite propriedade para determinar se a instância atual oferece suporte à gravação.Use the CanWrite property to determine whether the current instance supports writing.
Notas aos Herdeiros
A implementação padrão em Stream cria uma nova matriz de byte único e, em seguida, chama Write(Byte[], Int32, Int32) .The default implementation on Stream creates a new single-byte array and then calls Write(Byte[], Int32, Int32). Embora isso seja formalmente correto, ele é ineficiente.While this is formally correct, it is inefficient. Qualquer fluxo com um buffer interno deve substituir esse método e fornecer uma versão muito mais eficiente que grava no buffer diretamente, evitando a alocação de matriz extra em cada chamada.Any stream with an internal buffer should override this method and provide a much more efficient version that writes to the buffer directly, avoiding the extra array allocation on every call.