# GetHashCode()

> Returns the hash code 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 int GetHashCode()
```

### Returns

| Type                                                       | Description                                                                   |
| ---------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The hash code representing the node identifier and position of this location. |

### Remarks

The returned value combines the [node](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navlocation/node.md) identifier and the [position](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navlocation/position.md) of this [NavLocation](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navlocation.md). The hash code is suitable for storing locations in hash-based collections such as Dictionary or HashSet. Two [NavLocation](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navlocation.md) values that compare equal through [NavLocation.Equals](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navlocation/equals.md) also produce the same hash code.

### Examples

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

public class NavLocationHashExample : MonoBehaviour
{
    readonly HashSet<NavLocation> m_Visited = new HashSet<NavLocation>();

    void Update()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavLocation current = world.MapLocation(transform.position, Vector3.one, 0);

        // The hash combines both the node and the exact position, so two locations on the same
        // polygon usually hash differently, though hash collisions are still possible. Key on
        // NavLocation only when the precise point matters; to track which polygons have been
        // visited, key on NavNode instead.
        if (world.IsValid(current) && m_Visited.Add(current))
            Debug.Log($"Visited new location, hash {current.GetHashCode()}");
    }
}
```
