# TableEntryReference

> A serializable reference to a single table entry, identified either by its key text or by its stable key id.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Localization](/engine/6000.7/script-reference/unity/localization.md)
* **Assembly:** UnityEngine.LocalizationRuntimeModule
* **Implements:** [IEquatable\<TableEntryReference>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct TableEntryReference : IEquatable<TableEntryReference>
```

## Remarks

An entry reference addresses one row inside a table collection without holding a direct object reference. It stores either the key text or the numeric key id; [TableEntryReference.ReferenceType](/engine/6000.7/script-reference/unity/localization/tableentryreference/referencetype.md) reports which form is present, and [TableEntryReference.IsEmpty](/engine/6000.7/script-reference/unity/localization/tableentryreference/isempty.md) is `true` when neither is set. Key ids are stable across key renames, so they are the safer choice for serialized data, while key text is more readable in code. Convert between the two forms with [TableEntryReference.ResolveKeyId](/engine/6000.7/script-reference/unity/localization/tableentryreference/resolvekeyid.md) and [TableEntryReference.ResolveKeyName](/engine/6000.7/script-reference/unity/localization/tableentryreference/resolvekeyname.md), passing the collection's [SharedTableData](/engine/6000.7/script-reference/unity/localization/sharedtabledata.md). Combine it with a [TableReference](/engine/6000.7/script-reference/unity/localization/tablereference.md) to address an entry in a specific collection.

Additional Resources: [TableReference](/engine/6000.7/script-reference/unity/localization/tablereference.md), [ResourceDatabase](/engine/6000.7/script-reference/unity/localization/resourcedatabase.md), [ResourceTable](/engine/6000.7/script-reference/unity/localization/resourcetable.md)

Create entry references by key text and by key id, then resolve one to an id.

## Examples

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

namespace Unity.Localization.Samples
{
    public class TableEntryReferenceOverviewExample
    {
        public void Run(SharedTableData sharedData)
        {
            TableEntryReference byKey = "Menu/Start";   // implicit conversion from string
            TableEntryReference byId = 12345L;           // implicit conversion from long

            long id = byKey.ResolveKeyId(sharedData);
            Debug.Log($"{id} {byId.KeyId}");
        }
    }
}
```

## Properties

| Property                                                                                                 | Description                                                                                |
| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| [IsEmpty](/engine/6000.7/script-reference/unity/localization/tableentryreference/isempty.md)             | Whether this reference points at nothing.                                                  |
| [Key](/engine/6000.7/script-reference/unity/localization/tableentryreference/key.md)                     | The key text of the referenced entry, or null when the reference is empty or id-based.     |
| [KeyId](/engine/6000.7/script-reference/unity/localization/tableentryreference/keyid.md)                 | The stable key id of the referenced entry, or 0 when the reference is empty or name-based. |
| [ReferenceType](/engine/6000.7/script-reference/unity/localization/tableentryreference/referencetype.md) | How this reference identifies its entry.                                                   |

## Methods

| Method                                                                                                     | Description                                                                    |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [Equals](/engine/6000.7/script-reference/unity/localization/tableentryreference/equals.md)                 | Checks whether this reference equals another object.                           |
| [GetHashCode](/engine/6000.7/script-reference/unity/localization/tableentryreference/gethashcode.md)       | Computes a hash code for this reference.                                       |
| [ResolveKeyId](/engine/6000.7/script-reference/unity/localization/tableentryreference/resolvekeyid.md)     | Resolves this reference to a numeric key id using the given shared table data. |
| [ResolveKeyName](/engine/6000.7/script-reference/unity/localization/tableentryreference/resolvekeyname.md) | Resolves this reference to a key name using the given shared table data.       |
| [ToString](/engine/6000.7/script-reference/unity/localization/tableentryreference/tostring.md)             | Returns a readable string describing this reference.                           |

## Operators

| Operator                                                                                                     | Description                                         |
| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- |
| [TableEntryReference](/engine/6000.7/script-reference/unity/localization/tableentryreference/op-implicit.md) | Converts a key id into an id-based entry reference. |

## Enums

| Enum                                                                                                       | Description                                           |
| ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| [TableEntryReference.Type](/engine/6000.7/script-reference/unity/localization/tableentryreference/type.md) | The way a table entry reference identifies its entry. |
