> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.ksbitistream.md).

# Class ksBitIStream

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

Bit stream reader

```csharp
[Obsolete("Use ksBitReader instead.")]
public class ksBitIStream
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksBitIStream](/reactor/api-reference/ks.reactor/ks.reactor.ksbitistream.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksBitIStream(IList\<byte>) <a href="#ks_reactor_ksbitistream__ctor_system_collections_generic_ilist_system_byte" id="ks_reactor_ksbitistream__ctor_system_collections_generic_ilist_system_byte"></a>

Constructor

```csharp
public ksBitIStream(IList<byte> data)
```

#### Parameters

`data` [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)<[byte](https://learn.microsoft.com/dotnet/api/system.byte)>

data to read from.

## Methods

### Align() <a href="#ks_reactor_ksbitistream_align" id="ks_reactor_ksbitistream_align"></a>

Advances the position to the next byte if the position is not at a byte boundary.

```csharp
public void Align()
```

### GetBitPosition() <a href="#ks_reactor_ksbitistream_getbitposition" id="ks_reactor_ksbitistream_getbitposition"></a>

Gets the current bit position.

```csharp
public int GetBitPosition()
```

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

Current bit position.

### GetPosition() <a href="#ks_reactor_ksbitistream_getposition" id="ks_reactor_ksbitistream_getposition"></a>

Gets tje current byte position.

```csharp
public int GetPosition()
```

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

Current byte position.

### GetRemaining() <a href="#ks_reactor_ksbitistream_getremaining" id="ks_reactor_ksbitistream_getremaining"></a>

Gets the number of bytes in the buffer after the current position.

```csharp
public int GetRemaining()
```

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

Number of bytes in the buffer after the current position.

### ReadBits(int) <a href="#ks_reactor_ksbitistream_readbits_system_int32" id="ks_reactor_ksbitistream_readbits_system_int32"></a>

Reads up to 32 bits from the buffer.

```csharp
public uint ReadBits(int bits)
```

#### Parameters

`bits` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Number of bits to read.

#### Returns

[uint](https://learn.microsoft.com/dotnet/api/system.uint32)

Value

### ReadBits64(int) <a href="#ks_reactor_ksbitistream_readbits64_system_int32" id="ks_reactor_ksbitistream_readbits64_system_int32"></a>

Reads up to 64 bits from the buffer.

```csharp
public ulong ReadBits64(int bits)
```

#### Parameters

`bits` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Number of bits to read.

#### Returns

[ulong](https://learn.microsoft.com/dotnet/api/system.uint64)

Value

### ReadEncodedInt() <a href="#ks_reactor_ksbitistream_readencodedint" id="ks_reactor_ksbitistream_readencodedint"></a>

Reads an int converted from a uint.

```csharp
public int ReadEncodedInt()
```

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

Value.

### ReadEncodedLong() <a href="#ks_reactor_ksbitistream_readencodedlong" id="ks_reactor_ksbitistream_readencodedlong"></a>

Reads a long converted from a ulong.

```csharp
public long ReadEncodedLong()
```

#### Returns

[long](https://learn.microsoft.com/dotnet/api/system.int64)

Value.

### ReadEncodedString() <a href="#ks_reactor_ksbitistream_readencodedstring" id="ks_reactor_ksbitistream_readencodedstring"></a>

Reads a string.

```csharp
public string ReadEncodedString()
```

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

Value.

### ReadEncodedUInt() <a href="#ks_reactor_ksbitistream_readencodeduint" id="ks_reactor_ksbitistream_readencodeduint"></a>

Reads a uint.

```csharp
public uint ReadEncodedUInt()
```

#### Returns

[uint](https://learn.microsoft.com/dotnet/api/system.uint32)

Value.

### ReadEncodedULong() <a href="#ks_reactor_ksbitistream_readencodedulong" id="ks_reactor_ksbitistream_readencodedulong"></a>

Reads a ulong.V

```csharp
public ulong ReadEncodedULong()
```

#### Returns

[ulong](https://learn.microsoft.com/dotnet/api/system.uint64)

Value.

### ReadMultiType() <a href="#ks_reactor_ksbitistream_readmultitype" id="ks_reactor_ksbitistream_readmultitype"></a>

Reads a multi type.

```csharp
[Obsolete("This deserializes a multitype using the legacy format from Reactor 1.0.3 and earlier. Use a ksStreamBuffer to deserialize a multitype using the new format.")]
public ksMultiType ReadMultiType()
```

#### Returns

[ksMultiType](/reactor/api-reference/ks.reactor/ks.reactor.ksmultitype.md)

Value.

### Seek(int) <a href="#ks_reactor_ksbitistream_seek_system_int32" id="ks_reactor_ksbitistream_seek_system_int32"></a>

Seeks to a byte position.

```csharp
public void Seek(int position)
```

#### Parameters

`position` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Position to seek to.

### SeekBit(int) <a href="#ks_reactor_ksbitistream_seekbit_system_int32" id="ks_reactor_ksbitistream_seekbit_system_int32"></a>

Seeks to a bit position.

```csharp
public void SeekBit(int bit)
```

#### Parameters

`bit` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Bit to seek to.

### SeekOffset(int) <a href="#ks_reactor_ksbitistream_seekoffset_system_int32" id="ks_reactor_ksbitistream_seekoffset_system_int32"></a>

Adds an offset to the current position.

```csharp
public void SeekOffset(int offset)
```

#### Parameters

`offset` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Offset to add in bytes.
