# ToArray

> Returns a new managed array with all the elements copied from a set.

## Definition

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

## ToArray\<T>(NativeHashSet\<T>)

Returns a new managed array with all the elements copied from a set.

```csharp
[ExcludeFromBurstCompatTesting("Returns managed array")]
public static T[] ToArray<T>(this NativeHashSet<T> set) where T : unmanaged, IEquatable<T>
```

### Parameters

**** (\[NativeHashSet\<T>]\(/engine/6000.7/script-reference/unity/collections/nativehashset1)): The set whose elements are copied to the array.

### Returns

| Type              | Description                                                  |
| ----------------- | ------------------------------------------------------------ |
| [\<T>\[\]](./.md) | A new managed array with all the elements copied from a set. |

## ToArray\<T>(NativeParallelHashSet\<T>)

Returns a new managed array with all the elements copied from a set.

```csharp
[ExcludeFromBurstCompatTesting("Returns managed array")]
public static T[] ToArray<T>(this NativeParallelHashSet<T> set) where T : unmanaged, IEquatable<T>
```

### Parameters

**** (\[NativeParallelHashSet\<T>]\(/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1)): The set whose elements are copied to the array.

### Returns

| Type              | Description                                                  |
| ----------------- | ------------------------------------------------------------ |
| [\<T>\[\]](./.md) | A new managed array with all the elements copied from a set. |
