# GetHashCode()

> Obtains the hash code of this NavNode for use in 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) | The hash code derived from the node identifier, suitable for use in hash-based collections. |

### Remarks

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

### Examples

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

public class NavNodeHashExample : MonoBehaviour
{
    readonly HashSet<NavNode> m_VisitedNodes = new HashSet<NavNode>();

    void Update()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavLocation location = world.MapLocation(transform.position, Vector3.one, 0);
        if (world.IsValid(location) && m_VisitedNodes.Add(location.node))
            Debug.Log($"Recorded new node, hash {location.node.GetHashCode()}");
    }
}
```
