# GetEntry

> Returns the entry stored for a stable key id.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Localization](/engine/6000.7/script-reference/unity/localization.md)
* **Assembly:** UnityEngine.LocalizationRuntimeModule

## GetEntry(long)

Returns the entry stored for a stable key id.

```csharp
public IResourceEntry GetEntry(long keyId)
```

### Parameters

**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The stable key id to look up.

### Returns

| Type                                                                                   | Description                                     |
| -------------------------------------------------------------------------------------- | ----------------------------------------------- |
| [IResourceEntry](/engine/6000.7/script-reference/unity/localization/iresourceentry.md) | The matching entry, or `null` when none exists. |

### Remarks

Looks the id up among this table's entries. Returns `null` when the id is `0` or when no entry exists for it. To narrow the result to a specific entry kind, use [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md).

Additional Resources: [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [ResourceTable.AddEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/addentry.md)

Look up an entry by the key id of a previously added string.

### Examples

```csharp
using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples
{
    public class ResourceTableGetEntryByIdExample
    {
        public void Run()
        {
            var shared = ScriptableObject.CreateInstance<SharedTableData>();
            var table = ScriptableObject.CreateInstance<ResourceTable>();
            table.SharedData = shared;
            table.LocaleIdentifier = "en";

            var added = table.AddStringEntry("Greeting", "Hello");

            IResourceEntry entry = table.GetEntry(added.KeyId);
            Debug.Log(entry != null); // True
        }
    }
}
```

## GetEntry\<T>(long)

Returns the entry stored for a stable key id as a specific entry kind.

```csharp
public T GetEntry<T>(long keyId) where T : class, IResourceEntry
```

### Parameters

**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The stable key id to look up.

### Returns

| Type | Description                                                                  |
| ---- | ---------------------------------------------------------------------------- |
| T    | The matching entry as `T`, or `null` when it is missing or a different kind. |

### Remarks

Casts the result of [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md) to `T`. Returns `null` when no entry exists for the id or when the entry is not of that kind. Pass an entry class such as [StringEntry](/engine/6000.7/script-reference/unity/localization/stringentry.md) or a view interface such as [IStringEntry](/engine/6000.7/script-reference/unity/localization/istringentry.md).

Additional Resources: [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [IStringEntry](/engine/6000.7/script-reference/unity/localization/istringentry.md)

Read a value by fetching the entry as a typed string entry.

### Examples

```csharp
using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples
{
    public class ResourceTableGetEntryOfTypeByIdExample
    {
        public void Run()
        {
            var shared = ScriptableObject.CreateInstance<SharedTableData>();
            var table = ScriptableObject.CreateInstance<ResourceTable>();
            table.SharedData = shared;
            table.LocaleIdentifier = "en";

            var added = table.AddStringEntry("Greeting", "Hello");

            StringEntry entry = table.GetEntry<StringEntry>(added.KeyId);
            Debug.Log(entry.Value); // Hello
        }
    }
}
```

## GetEntry(string)

Returns the entry stored for a key.

```csharp
public IResourceEntry GetEntry(string key)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The key text to look up.

### Returns

| Type                                                                                   | Description                                     |
| -------------------------------------------------------------------------------------- | ----------------------------------------------- |
| [IResourceEntry](/engine/6000.7/script-reference/unity/localization/iresourceentry.md) | The matching entry, or `null` when none exists. |

### Remarks

Resolves the key text to its stable id through [ResourceTable.SharedData](/engine/6000.7/script-reference/unity/localization/resourcetable/shareddata.md), then returns the matching entry. Returns `null` when no shared data is assigned, the key is absent, or this table has no entry for it. To narrow the result to a specific entry kind, use [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md).

Additional Resources: [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [ResourceTable.SharedData](/engine/6000.7/script-reference/unity/localization/resourcetable/shareddata.md)

Look up an entry by its key text.

### Examples

```csharp
using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples
{
    public class ResourceTableGetEntryByKeyExample
    {
        public void Run()
        {
            var shared = ScriptableObject.CreateInstance<SharedTableData>();
            var table = ScriptableObject.CreateInstance<ResourceTable>();
            table.SharedData = shared;
            table.LocaleIdentifier = "en";

            table.AddStringEntry("Greeting", "Hello");

            IResourceEntry entry = table.GetEntry("Greeting");
            Debug.Log(entry != null); // True
        }
    }
}
```

## GetEntry\<T>(string)

Returns the entry stored for a key as a specific entry kind.

```csharp
public T GetEntry<T>(string key) where T : class, IResourceEntry
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The key text to look up.

### Returns

| Type | Description                                                                  |
| ---- | ---------------------------------------------------------------------------- |
| T    | The matching entry as `T`, or `null` when it is missing or a different kind. |

### Remarks

Resolves the key text through [ResourceTable.SharedData](/engine/6000.7/script-reference/unity/localization/resourcetable/shareddata.md), then casts the result of [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md) to `T`. Returns `null` when the key cannot be resolved, no entry exists, or the entry is not of that kind. Pass an entry class such as [StringEntry](/engine/6000.7/script-reference/unity/localization/stringentry.md) or a view interface such as [IStringEntry](/engine/6000.7/script-reference/unity/localization/istringentry.md).

Additional Resources: [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [ResourceTable.GetEntry](/engine/6000.7/script-reference/unity/localization/resourcetable/getentry.md), [IStringEntry](/engine/6000.7/script-reference/unity/localization/istringentry.md)

Read a value by fetching the entry for a key as a typed string entry.

### Examples

```csharp
using Unity.Localization;
using UnityEngine;

namespace Unity.Localization.Samples
{
    public class ResourceTableGetEntryOfTypeByKeyExample
    {
        public void Run()
        {
            var shared = ScriptableObject.CreateInstance<SharedTableData>();
            var table = ScriptableObject.CreateInstance<ResourceTable>();
            table.SharedData = shared;
            table.LocaleIdentifier = "en";

            table.AddStringEntry("Greeting", "Hello");

            IStringEntry entry = table.GetEntry<IStringEntry>("Greeting");
            Debug.Log(entry.Value); // Hello
        }
    }
}
```
