# DataStreamWriter

> Initializes a new instance of the DataStreamWriter struct.

## Definition

* **Type:** Constructor
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## DataStreamWriter(int, AllocatorHandle)

Initializes a new instance of the DataStreamWriter struct.

```csharp
public DataStreamWriter(int length, AllocatorManager.AllocatorHandle allocator)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes available in the buffer.**** (\[AllocatorHandle]\(/engine/6000.7/script-reference/unity/collections/allocatormanager/allocatorhandle)): The [Allocator](/engine/6000.7/script-reference/unity/collections/allocator.md) used to allocate the memory.

## DataStreamWriter(NativeArray\<byte>)

Initializes a new instance of the DataStreamWriter struct with a NativeArray\\\<byte\\>

```csharp
public DataStreamWriter(NativeArray<byte> data)
```

### Parameters

**** (\[NativeArray\<byte>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The buffer to attach to the DataStreamWriter.

## DataStreamWriter(byte\*, int)

Initializes a new instance of the DataStreamWriter struct with a memory we don't own

```csharp
public DataStreamWriter(byte* data, int length)
```

### Parameters

**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): Pointer to the data**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Length of the data
