---
title: Add
product: Unity Editor
version: '6000.7'
latest_version: '7000.0'
status: This page documents version 6000.7. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeparallelhashset1/parallelwriter/add
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/collections/lowlevel/unsafe/unsafeparallelhashset1/parallelwriter/add.md
last_updated: 2026-09-14
generated_at: 2026-11-15T12:36:10.960Z
locale: en-us
---

# Add

> Adds a new item. If the item is already present in the collection, this method should throw, but currently does not! Instead, it returns false without replacing said item.

## Definition

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

## Add(T)

Adds a new item. If the item is already present in the collection, this method **should** throw, but currently does not! Instead, it returns false without replacing said item.

```csharp
public bool Add(T item)
```

### Parameters

**** (T): The value to add.

### Returns

| Type                                                          | Description                               |
| ------------------------------------------------------------- | ----------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the value is not already present. |

### Remarks

Prefer [UnsafeParallelHashSet\<T>.ParallelWriter.TryAdd](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeparallelhashset1/parallelwriter/tryadd.md) if your intent is to allow graceful failure, as this API will eventually become more strict (and begin to throw).

## Add(T, int)

Adds a new item. If the item is already present in the collection, this method **should** throw, but currently does not! Instead, it returns false without replacing said item.

```csharp
public bool Add(T item, int threadIndexOverride)
```

### Parameters

**** (T): The value to add.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The thread index which must be set by a field from a job struct with the NativeSetThreadIndexAttribute attribute.

### Returns

| Type                                                          | Description                               |
| ------------------------------------------------------------- | ----------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the value is not already present. |

### Remarks

Prefer [UnsafeParallelHashSet\<T>.ParallelWriter.TryAdd](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeparallelhashset1/parallelwriter/tryadd.md) if your intent is to allow graceful failure, as this API will eventually become more strict (and begin to throw).
