# GetHashCode()

> Computes a hash code for identifying this NavQueryBuffer in hash-based collections.

## Definition

* **Type:** Method
* **Namespace:** [Unity.AI.Navigation.LowLevel](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel.md)
* **Assembly:** UnityEngine.AIModule

```csharp
public override readonly int GetHashCode()
```

### Returns

| Type                                                       | Description                                                           |
| ---------------------------------------------------------- | --------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | A hash code derived from the buffer's internal allocation identifier. |

### Remarks

The returned value is suitable for storing the NavQueryBuffer in hash-based collections such as Dictionary or HashSet. Two NavQueryBuffer values that compare equal through [NavQueryBuffer.Equals](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navquerybuffer/equals.md) also produce the same hash code.

### Examples

```csharp
using System.Collections.Generic;
using Unity.Collections;
using UnityEngine;
using Unity.AI.Navigation.LowLevel;

public class NavQueryBufferHashExample : MonoBehaviour
{
    readonly Dictionary<NavQueryBuffer, string> m_Labels = new Dictionary<NavQueryBuffer, string>();
    NavWorld m_World;
    NavQueryBuffer m_Buffer;

    void OnEnable()
    {
        m_World = NavWorld.GetDefaultWorld();
        m_Buffer = new NavQueryBuffer(m_World, Allocator.Persistent, 1024);
        m_Labels[m_Buffer] = "main";
        Debug.Log($"Registered buffer with hash {m_Buffer.GetHashCode()}");
    }

    void OnDisable()
    {
        // Drop the key before disposing, otherwise the dictionary keeps a stale buffer
        // whose hash no longer matches the disposed allocation.
        m_Labels.Remove(m_Buffer);

        m_Buffer.Dispose();
        m_World.Dispose();
    }
}
```
