> 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.ksbitostream.md).

# Class ksBitOStream

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

Bit stream writer

```csharp
[Obsolete("Use ksBitWriter instead.")]
public class ksBitOStream
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksBitOStream](/reactor/api-reference/ks.reactor/ks.reactor.ksbitostream.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

### ksBitOStream(List\<byte>) <a href="#ks_reactor_ksbitostream__ctor_system_collections_generic_list_system_byte" id="ks_reactor_ksbitostream__ctor_system_collections_generic_list_system_byte"></a>

Constructor

```csharp
public ksBitOStream(List<byte> buffer)
```

#### Parameters

`buffer` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)<[byte](https://learn.microsoft.com/dotnet/api/system.byte)>

buffer to write to.

## Methods

### Align() <a href="#ks_reactor_ksbitostream_align" id="ks_reactor_ksbitostream_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_ksbitostream_getbitposition" id="ks_reactor_ksbitostream_getbitposition"></a>

Gets the bit position.

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

#### Returns

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

bit position.

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

Gets the byte position.

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

#### Returns

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

byte position.

### Seek(int) <a href="#ks_reactor_ksbitostream_seek_system_int32" id="ks_reactor_ksbitostream_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_ksbitostream_seekbit_system_int32" id="ks_reactor_ksbitostream_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_ksbitostream_seekoffset_system_int32" id="ks_reactor_ksbitostream_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.

### WriteBits(uint, int) <a href="#ks_reactor_ksbitostream_writebits_system_uint32_system_int32" id="ks_reactor_ksbitostream_writebits_system_uint32_system_int32"></a>

Writes up to 32 bits into the buffer.

```csharp
public void WriteBits(uint input, int bits)
```

#### Parameters

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

input to write bits from.

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

number of bits from input to write.

### WriteBits64(ulong, int) <a href="#ks_reactor_ksbitostream_writebits64_system_uint64_system_int32" id="ks_reactor_ksbitostream_writebits64_system_uint64_system_int32"></a>

Writes up to 64 bits into the buffer.

```csharp
public void WriteBits64(ulong input, int bits)
```

#### Parameters

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

input to write bits from.

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

number of bits from input to write.

### WriteEncodedValue(uint) <a href="#ks_reactor_ksbitostream_writeencodedvalue_system_uint32" id="ks_reactor_ksbitostream_writeencodedvalue_system_uint32"></a>

Writes a uint.

```csharp
public void WriteEncodedValue(uint input)
```

#### Parameters

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

input to write.

### WriteEncodedValue(int) <a href="#ks_reactor_ksbitostream_writeencodedvalue_system_int32" id="ks_reactor_ksbitostream_writeencodedvalue_system_int32"></a>

Writes an int converted to a uint.

```csharp
public void WriteEncodedValue(int input)
```

#### Parameters

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

input to write.

### WriteEncodedValue(ulong) <a href="#ks_reactor_ksbitostream_writeencodedvalue_system_uint64" id="ks_reactor_ksbitostream_writeencodedvalue_system_uint64"></a>

Writes a ulong.

```csharp
public void WriteEncodedValue(ulong input)
```

#### Parameters

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

input to write.

### WriteEncodedValue(long) <a href="#ks_reactor_ksbitostream_writeencodedvalue_system_int64" id="ks_reactor_ksbitostream_writeencodedvalue_system_int64"></a>

Writes a long converted to a ulong.

```csharp
public void WriteEncodedValue(long input)
```

#### Parameters

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

input to write.

### WriteEncodedValue(string) <a href="#ks_reactor_ksbitostream_writeencodedvalue_system_string" id="ks_reactor_ksbitostream_writeencodedvalue_system_string"></a>

Writes a string. Serializes null as empty string.

```csharp
public void WriteEncodedValue(string input)
```

#### Parameters

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

input to write.

### WriteMultiType(ksMultiType) <a href="#ks_reactor_ksbitostream_writemultitype_ks_reactor_ksmultitype" id="ks_reactor_ksbitostream_writemultitype_ks_reactor_ksmultitype"></a>

Writes a [ksMultiType](/reactor/api-reference/ks.reactor/ks.reactor.ksmultitype.md). This is not implemented.

```csharp
[Obsolete]
public void WriteMultiType(ksMultiType input)
```

#### Parameters

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

input to write.
