# TryAdd

> Adds a new value. If the item is already present, this method returns false without replacing said item.

## Definition

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

## TryAdd(T)

Adds a new value. If the item is already present, this method returns false without replacing said item.

```csharp
public bool TryAdd(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. |

## TryAdd(T, int)

Adds a new value. If the item is already present, this method returns false without replacing said item.

```csharp
public bool TryAdd(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. |
