class BinaryWriter
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.
outputThe output stream.
public BinaryWriter( Stream output, Encoding encoding )
Initializes a new instance of the class based on the specified stream and character encoding.
outputThe output stream.encodingThe 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.
outputThe output stream.encodingThe character encoding to use.leaveOpento 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.
offsetA byte offset relative to .originA 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 .
valueThe 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.
valueThe unsigned byte to write.
public void Write( byte[] buffer )
Writes a byte array to the underlying stream.
bufferA 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.
bufferA byte array containing the data to write.indexThe index of the first byte to read from and to write to the stream.countThe 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.
chThe 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.
charsA 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.
charsA character array containing the data to write.indexThe index of the first character to read from and to write to the stream.countThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe 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.
valueThe eight-byte unsigned integer to write.
public void Write7BitEncodedInt( int value )
Writes a 32-bit integer in a compressed format.
valueThe 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.