# SetBits

> Sets a single bit to 1 or 0.

## Definition

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

## SetBits(int, bool)

Sets a single bit to 1 or 0.

```csharp
public void SetBits(int pos, bool value)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Position in this bit field to set (must be 0-63).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, sets the bit to 1. If false, sets the bit to 0.

## SetBits(int, bool, int)

Sets one or more contiguous bits to 1 or 0.

```csharp
public void SetBits(int pos, bool value, int numBits = 1)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Position in the bit field of the first bit to set (must be 0-63).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, sets the bits to 1. If false, sets the bits to 0.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of bits to set (must be 1-64).
