Class BitArrayReader
- Namespace
- Ecng.Collections
- Assembly
- Ecng.Collections.dll
Provides a reader for bit-level data from a stream.
public class BitArrayReader
- Inheritance
-
BitArrayReader
- Inherited Members
- Extension Methods
Constructors
BitArrayReader(Stream)
Initializes a new instance of the BitArrayReader class with the specified underlying stream.
public BitArrayReader(Stream underlyingStream)
Parameters
underlyingStream
StreamThe stream to read bit-level data from.
Exceptions
- ArgumentNullException
Thrown if
underlyingStream
is null.
Properties
Offset
Gets or sets the current bit offset within the stream.
public long Offset { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Thrown if the value is negative.
Methods
Read()
Reads a single bit from the stream.
public bool Read()
Returns
- bool
The value of the bit read.
Read(int)
Reads a specified number of bits from the stream as an integer.
public int Read(int count)
Parameters
count
intThe number of bits to read.
Returns
- int
The integer value represented by the bits read.
Exceptions
- ArgumentOutOfRangeException
Thrown if
count
is invalid.
ReadArray(int)
Reads an array of bits from the stream.
public bool[] ReadArray(int count)
Parameters
count
intThe number of bits to read.
Returns
- bool[]
An array of boolean values representing the bits read.
ReadDecimal()
Reads a decimal value from the stream.
public decimal ReadDecimal()
Returns
- decimal
The decimal value read from the stream.
ReadInt()
Reads an integer value from the stream using a variable-length encoding.
public int ReadInt()
Returns
- int
The integer value read from the stream.
ReadLong()
Reads a long integer value from the stream using a variable-length encoding.
public long ReadLong()
Returns
- long
The long integer value read from the stream.
ReadLong(int)
Reads a specified number of bits from the stream as a long integer.
public long ReadLong(int count)
Parameters
count
intThe number of bits to read.
Returns
- long
The long integer value represented by the bits read.
Exceptions
- ArgumentOutOfRangeException
Thrown if
count
is invalid.
Seek(int)
Moves the current bit offset by the specified number of bits.
public void Seek(int offset)
Parameters
offset
intThe number of bits to move the offset by.