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

# Class ksOutputBuffer

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

This output buffer converts each written element into one or two byte arrays and adds them to a list. When the output is requested, by calls to GetBytes() or Flush(), the list of byte arrays is copied to a single byte array. This approach is significatly faster for large amounts of data when compared to using memory streams or resizing an array for each write operation.

```csharp
[Obsolete("Use ksStreamBuffer instead.")]
public class ksOutputBuffer
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksOutputBuffer](/reactor/api-reference/ks.reactor/ks.reactor.ksoutputbuffer.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)

## Properties

### Length <a href="#ks_reactor_ksoutputbuffer_length" id="ks_reactor_ksoutputbuffer_length"></a>

Gets the current byte length of the buffer.

```csharp
public int Length { get; }
```

#### Property Value

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

### Subbuffers <a href="#ks_reactor_ksoutputbuffer_subbuffers" id="ks_reactor_ksoutputbuffer_subbuffers"></a>

Gets the list of subbuffers(byte\[]) that make up the buffer.

```csharp
public List<byte[]> Subbuffers { get; }
```

#### Property Value

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

## Methods

### Clear() <a href="#ks_reactor_ksoutputbuffer_clear" id="ks_reactor_ksoutputbuffer_clear"></a>

Clears the buffer.

```csharp
public void Clear()
```

### Flush() <a href="#ks_reactor_ksoutputbuffer_flush" id="ks_reactor_ksoutputbuffer_flush"></a>

Gets the buffer bytes then clear the buffer.

```csharp
public byte[] Flush()
```

#### Returns

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

Byte array.

### GetBytes() <a href="#ks_reactor_ksoutputbuffer_getbytes" id="ks_reactor_ksoutputbuffer_getbytes"></a>

Copies and returns the contents of the buffer as a single byte array.

```csharp
public byte[] GetBytes()
```

#### Returns

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

Byte array.

### Write(bool) <a href="#ks_reactor_ksoutputbuffer_write_system_boolean" id="ks_reactor_ksoutputbuffer_write_system_boolean"></a>

Writes a bool to the buffer.

```csharp
public void Write(bool value)
```

#### Parameters

`value` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Bool to write.

### Write\<T>(T) <a href="#ks_reactor_ksoutputbuffer_write__1___0" id="ks_reactor_ksoutputbuffer_write__1___0"></a>

Writes a struct of type T to the buffer.

```csharp
public void Write<T>(T value) where T : struct
```

#### Parameters

`value` T

Struct to write.

#### Type Parameters

`T`

### Write(byte) <a href="#ks_reactor_ksoutputbuffer_write_system_byte" id="ks_reactor_ksoutputbuffer_write_system_byte"></a>

Writes a byte to the buffer.

```csharp
public void Write(byte value)
```

#### Parameters

`value` [byte](https://learn.microsoft.com/dotnet/api/system.byte)

Byte to write.

### Write(char) <a href="#ks_reactor_ksoutputbuffer_write_system_char" id="ks_reactor_ksoutputbuffer_write_system_char"></a>

Writes a char to the buffer.

```csharp
public void Write(char value)
```

#### Parameters

`value` [char](https://learn.microsoft.com/dotnet/api/system.char)

Char to write.

### Write(short) <a href="#ks_reactor_ksoutputbuffer_write_system_int16" id="ks_reactor_ksoutputbuffer_write_system_int16"></a>

Writes a short to the buffer.

```csharp
public void Write(short value)
```

#### Parameters

`value` [short](https://learn.microsoft.com/dotnet/api/system.int16)

Short to write.

### Write(ushort) <a href="#ks_reactor_ksoutputbuffer_write_system_uint16" id="ks_reactor_ksoutputbuffer_write_system_uint16"></a>

Writes a ushort to the buffer.

```csharp
public void Write(ushort value)
```

#### Parameters

`value` [ushort](https://learn.microsoft.com/dotnet/api/system.uint16)

Ushort to write.

### Write(int) <a href="#ks_reactor_ksoutputbuffer_write_system_int32" id="ks_reactor_ksoutputbuffer_write_system_int32"></a>

Writes a int to the buffer.

```csharp
public void Write(int value)
```

#### Parameters

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

Int to write.

### Write(uint) <a href="#ks_reactor_ksoutputbuffer_write_system_uint32" id="ks_reactor_ksoutputbuffer_write_system_uint32"></a>

Writes a uint to the buffer.

```csharp
public void Write(uint value)
```

#### Parameters

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

Uint to write.

### Write(long) <a href="#ks_reactor_ksoutputbuffer_write_system_int64" id="ks_reactor_ksoutputbuffer_write_system_int64"></a>

Writes a long to the buffer.

```csharp
public void Write(long value)
```

#### Parameters

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

Long to write.

### Write(ulong) <a href="#ks_reactor_ksoutputbuffer_write_system_uint64" id="ks_reactor_ksoutputbuffer_write_system_uint64"></a>

Writes a ulong to the buffer.

```csharp
public void Write(ulong value)
```

#### Parameters

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

Ulong to write.

### Write(float) <a href="#ks_reactor_ksoutputbuffer_write_system_single" id="ks_reactor_ksoutputbuffer_write_system_single"></a>

Writes a float to the buffer.

```csharp
public void Write(float value)
```

#### Parameters

`value` [float](https://learn.microsoft.com/dotnet/api/system.single)

Float to write.

### Write(double) <a href="#ks_reactor_ksoutputbuffer_write_system_double" id="ks_reactor_ksoutputbuffer_write_system_double"></a>

Writes a double to the buffer.

```csharp
public void Write(double value)
```

#### Parameters

`value` [double](https://learn.microsoft.com/dotnet/api/system.double)

Double to write.

### Write(string) <a href="#ks_reactor_ksoutputbuffer_write_system_string" id="ks_reactor_ksoutputbuffer_write_system_string"></a>

Writes a string to the buffer.

```csharp
public void Write(string value)
```

#### Parameters

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

String to write.

### Write(bool\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_boolean" id="ks_reactor_ksoutputbuffer_write_system_boolean"></a>

Writes an array of bools to the buffer. Values are first converted to a bit array before writing. If the array is null, then a length of -1 is written.

```csharp
public void Write(bool[] value)
```

#### Parameters

`value` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)\[]

Bool array to write.

### Write(byte\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_byte" id="ks_reactor_ksoutputbuffer_write_system_byte"></a>

Writes an array of bytes to the buffer.

```csharp
public void Write(byte[] value)
```

#### Parameters

`value` [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[]

Byte array to write.

### Write(char\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_char" id="ks_reactor_ksoutputbuffer_write_system_char"></a>

Writes an array of chars to the buffer.

```csharp
public void Write(char[] value)
```

#### Parameters

`value` [char](https://learn.microsoft.com/dotnet/api/system.char)\[]

Char array to write.

### Write(short\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_int16" id="ks_reactor_ksoutputbuffer_write_system_int16"></a>

Writes an array of shorts to the buffer.

```csharp
public void Write(short[] value)
```

#### Parameters

`value` [short](https://learn.microsoft.com/dotnet/api/system.int16)\[]

Short array to write.

### Write(ushort\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_uint16" id="ks_reactor_ksoutputbuffer_write_system_uint16"></a>

Writes an array of ushort to the buffer.

```csharp
public void Write(ushort[] value)
```

#### Parameters

`value` [ushort](https://learn.microsoft.com/dotnet/api/system.uint16)\[]

Ushort array to write.

### Write(int\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_int32" id="ks_reactor_ksoutputbuffer_write_system_int32"></a>

Writes an array of ints to the buffer.

```csharp
public void Write(int[] value)
```

#### Parameters

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

Int array to write.

### Write(uint\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_uint32" id="ks_reactor_ksoutputbuffer_write_system_uint32"></a>

Writes an array of uints to the buffer.

```csharp
public void Write(uint[] value)
```

#### Parameters

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

Uint array to write.

### Write(long\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_int64" id="ks_reactor_ksoutputbuffer_write_system_int64"></a>

Writes an array of longs to the buffer.

```csharp
public void Write(long[] value)
```

#### Parameters

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

Long array to write.

### Write(ulong\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_uint64" id="ks_reactor_ksoutputbuffer_write_system_uint64"></a>

Write an array of ulongs to the buffer.

```csharp
public void Write(ulong[] value)
```

#### Parameters

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

Ulong array to write.

### Write(float\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_single" id="ks_reactor_ksoutputbuffer_write_system_single"></a>

Writes an array of floats to the buffer.

```csharp
public void Write(float[] value)
```

#### Parameters

`value` [float](https://learn.microsoft.com/dotnet/api/system.single)\[]

Float array to write.

### Write(double\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_double" id="ks_reactor_ksoutputbuffer_write_system_double"></a>

Writes an array of doubles to the buffer.

```csharp
public void Write(double[] value)
```

#### Parameters

`value` [double](https://learn.microsoft.com/dotnet/api/system.double)\[]

Double array to write.

### Write(string\[]) <a href="#ks_reactor_ksoutputbuffer_write_system_string" id="ks_reactor_ksoutputbuffer_write_system_string"></a>

Writes an array of strings to the buffer. Writes the length of the array followed by each string. If the array is null, then a length of -1 is written.

```csharp
public void Write(string[] value)
```

#### Parameters

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

String array to write.

### Write(ksOutputBuffer) <a href="#ks_reactor_ksoutputbuffer_write_ks_reactor_ksoutputbuffer" id="ks_reactor_ksoutputbuffer_write_ks_reactor_ksoutputbuffer"></a>

Appends the contents of another output buffer.

```csharp
public void Write(ksOutputBuffer value)
```

#### Parameters

`value` [ksOutputBuffer](/reactor/api-reference/ks.reactor/ks.reactor.ksoutputbuffer.md)

Value to write.

### Write(ksIBufferable) <a href="#ks_reactor_ksoutputbuffer_write_ks_reactor_ksibufferable" id="ks_reactor_ksoutputbuffer_write_ks_reactor_ksibufferable"></a>

Writes the bytes of an object that implemented ksIBufferable. If the object is null write a length value of -1.

```csharp
public void Write(ksIBufferable value)
```

#### Parameters

`value` [ksIBufferable](/reactor/api-reference/ks.reactor/ks.reactor.ksibufferable.md)

Value to write.

### Write(ksMultiType) <a href="#ks_reactor_ksoutputbuffer_write_ks_reactor_ksmultitype" id="ks_reactor_ksoutputbuffer_write_ks_reactor_ksmultitype"></a>

Writes a ksMultitype to the buffer. This is not implemented and throws an exception.

```csharp
public void Write(ksMultiType value)
```

#### Parameters

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

Value to write.

### WriteBytes(byte\[]) <a href="#ks_reactor_ksoutputbuffer_writebytes_system_byte" id="ks_reactor_ksoutputbuffer_writebytes_system_byte"></a>

Writes bytes to the buffer.

```csharp
public void WriteBytes(byte[] bytes)
```

#### Parameters

`bytes` [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[]

Bytes to write.
