---
title: TryGetValue(TKey, out TValue)
product: Unity Editor
version: '6000.7'
latest_version: '7000.0'
status: This page documents version 6000.7. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafehashmap2/readonly/trygetvalue
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/collections/lowlevel/unsafe/unsafehashmap2/readonly/trygetvalue.md
last_updated: 2026-09-14
generated_at: 2026-11-14T09:25:58.760Z
locale: en-us
---

# TryGetValue(TKey, out TValue)

> Returns the value associated with a key.

## Definition

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

## TryGetValue(T, T)

```csharp
public readonly bool TryGetValue(TKey key, out TValue item)
```

### Parameters

**** (T): The key to look up.**** (T): Outputs the value associated with the key. Outputs default if the key was not present.

### Returns

| Type                                                          | Description                  |
| ------------------------------------------------------------- | ---------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the key was present. |
