# NativeKeyValueArrays<TKey, TValue>

> The keys and values of a hash map copied into two parallel arrays.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeDisposable](/engine/6000.7/script-reference/unity/collections/inativedisposable.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public struct NativeKeyValueArrays<TKey, TValue> : INativeDisposable, IDisposable where TKey : unmanaged where TValue : unmanaged
```

## Remarks

For each key-value pair copied from the hash map, the key is stored in `Keys[i]` while the value is stored in `Values[i]` (for the same `i`).

NativeKeyValueArrays is not actually itself a native collection: it contains a NativeArray for the keys and a NativeArray for the values, but a NativeKeyValueArrays does not have its own safety handles.

## Fields

| Value                                                                                       | Description |
| ------------------------------------------------------------------------------------------- | ----------- |
| [Keys](/engine/6000.7/script-reference/unity/collections/nativekeyvaluearrays2/keys.md)     | The keys.   |
| [Values](/engine/6000.7/script-reference/unity/collections/nativekeyvaluearrays2/values.md) | The values. |

## Constructors

| Constructor                                                                                                                                                                                                      | Description                                                  |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [NativeKeyValueArrays\`2(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle,Unity.Collections.NativeArrayOptions)](/engine/6000.7/script-reference/unity/collections/nativekeyvaluearrays2/ctor.md) | Initializes and returns an instance of NativeKeyValueArrays. |

## Properties

| Property                                                                                    | Description                    |
| ------------------------------------------------------------------------------------------- | ------------------------------ |
| [Length](/engine/6000.7/script-reference/unity/collections/nativekeyvaluearrays2/length.md) | The number of key-value pairs. |

## Methods

| Method                                                                                        | Description                                         |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| [Dispose](/engine/6000.7/script-reference/unity/collections/nativekeyvaluearrays2/dispose.md) | Releases all resources (memory and safety handles). |
