# Unique<T>(NativeArray<T>)

> Removes duplicate values from this sorted array and returns the number of values remaining.

## Definition

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

```csharp
public static int Unique<T>(this NativeArray<T> array) where T : unmanaged, IEquatable<T>
```

### Parameters

**** (\[NativeArray\<T>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The array from which to remove duplicates.

### Returns

| Type                                                       | Description                                  |
| ---------------------------------------------------------- | -------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of unique elements in this array. |

### Remarks

Uses `Equals` to determine whether values are duplicates.

Expects the array to already be sorted.

The remaining elements will be tightly packed at the front of the array.
