# UnsafeBitArray

> Initializes and returns an instance of UnsafeBitArray which aliases an existing buffer.

## Definition

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

## UnsafeBitArray(void\*, int, AllocatorHandle)

Initializes and returns an instance of UnsafeBitArray which aliases an existing buffer.

```csharp
public UnsafeBitArray(void* ptr, int sizeInBytes, AllocatorManager.AllocatorHandle allocator = default)
```

### Parameters

**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): An existing buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes. The length will be `sizeInBytes * 8`.**** (\[AllocatorHandle]\(/engine/6000.7/script-reference/unity/collections/allocatormanager/allocatorhandle)): The allocator that was used to allocate the bytes. Needed to dispose this array.

## UnsafeBitArray(int, AllocatorHandle, NativeArrayOptions)

Initializes and returns an instance of UnsafeBitArray.

```csharp
public UnsafeBitArray(int numBits, AllocatorManager.AllocatorHandle allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of bits.**** (\[AllocatorHandle]\(/engine/6000.7/script-reference/unity/collections/allocatormanager/allocatorhandle)): The allocator to use.**** (\[NativeArrayOptions]\(/engine/6000.7/script-reference/unity/collections/nativearrayoptions)): Whether newly allocated bytes should be zeroed out.
