class BinaryWriter

in global :: System . IO

Writes primitive types in binary to a stream and supports writing strings in a specific encoding.


public BinaryWriter( Stream output )

Initializes a new instance of the class based on the specified stream and using UTF-8 encoding.

  • output The output stream.

public BinaryWriter( Stream output, Encoding encoding )

Initializes a new instance of the class based on the specified stream and character encoding.

  • output The output stream.
  • encoding The character encoding to use.

public BinaryWriter( Stream output, Encoding encoding, bool leaveOpen )

Initializes a new instance of the class based on the specified stream and character encoding, and optionally leaves the stream open.

  • output The output stream.
  • encoding The character encoding to use.
  • leaveOpen to leave the stream open after the object is disposed; otherwise, .

public Stream BaseStream { get; }

Gets the underlying stream of the .

  • Returns The underlying stream associated with the .

public static BinaryWriter Null

Specifies a with no backing store.

public long Seek( int offset, SeekOrigin origin )

Sets the position within the current stream.

  • offset A byte offset relative to .
  • origin A field of indicating the reference point from which the new position is to be obtained.
  • Returns The position with the current stream.

public void Write( bool value )

Writes a one-byte value to the current stream, with 0 representing and 1 representing .

  • value The value to write (0 or 1).

public void Write( byte value )

Writes an unsigned byte to the current stream and advances the stream position by one byte.

  • value The unsigned byte to write.

public void Write( byte[] buffer )

Writes a byte array to the underlying stream.

  • buffer A byte array containing the data to write.

public void Write( byte[] buffer, int index, int count )

Writes a region of a byte array to the current stream.

  • buffer A byte array containing the data to write.
  • index The index of the first byte to read from and to write to the stream.
  • count The number of bytes to read from and to write to the stream.

public void Write( char ch )

Writes a Unicode character to the current stream and advances the current position of the stream in accordance with the used and the specific characters being written to the stream.

  • ch The non-surrogate, Unicode character to write.

public void Write( char[] chars )

Writes a character array to the current stream and advances the current position of the stream in accordance with the used and the specific characters being written to the stream.

  • chars A character array containing the data to write.

public void Write( char[] chars, int index, int count )

Writes a section of a character array to the current stream, and advances the current position of the stream in accordance with the used and perhaps the specific characters being written to the stream.

  • chars A character array containing the data to write.
  • index The index of the first character to read from and to write to the stream.
  • count The number of characters to read from and to write to the stream.

public void Write( decimal value )

Writes a decimal value to the current stream and advances the stream position by sixteen bytes.

  • value The decimal value to write.

public void Write( double value )

Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes.

  • value The eight-byte floating-point value to write.

public void Write( short value )

Writes a two-byte signed integer to the current stream and advances the stream position by two bytes.

  • value The two-byte signed integer to write.

public void Write( int value )

Writes a four-byte signed integer to the current stream and advances the stream position by four bytes.

  • value The four-byte signed integer to write.

public void Write( long value )

Writes an eight-byte signed integer to the current stream and advances the stream position by eight bytes.

  • value The eight-byte signed integer to write.

public void Write( sbyte value )

Writes a signed byte to the current stream and advances the stream position by one byte.

  • value The signed byte to write.

public void Write( float value )

Writes a four-byte floating-point value to the current stream and advances the stream position by four bytes.

  • value The four-byte floating-point value to write.

public void Write( string value )

Writes a length-prefixed string to this stream in the current encoding of the , and advances the current position of the stream in accordance with the encoding used and the specific characters being written to the stream.

  • value The value to write.

public void Write( ushort value )

Writes a two-byte unsigned integer to the current stream and advances the stream position by two bytes.

  • value The two-byte unsigned integer to write.

public void Write( uint value )

Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes.

  • value The four-byte unsigned integer to write.

public void Write( ulong value )

Writes an eight-byte unsigned integer to the current stream and advances the stream position by eight bytes.

  • value The eight-byte unsigned integer to write.

public void Write7BitEncodedInt( int value )

Writes a 32-bit integer in a compressed format.

  • value The 32-bit integer to be written.

public void Dispose( )

😔 No documentation found.

public ValueTask DisposeAsync( )

😔 No documentation found.

public int GetHashCode( )

😔 No documentation found.

public bool Equals( object obj )

😔 No documentation found.

public string ToString( )

😔 No documentation found.

public void Close( )

😔 No documentation found.

public void Write7BitEncodedInt64( long value )

😔 No documentation found.

public void Write( ReadOnlySpan<byte> buffer )

😔 No documentation found.

public void Write( Half value )

😔 No documentation found.

public void Flush( )

😔 No documentation found.

public Type GetType( )

😔 No documentation found.

public void Write( ReadOnlySpan<char> chars )

😔 No documentation found.