# TableReference

> A serializable reference to a table collection, identified either by its name or by its collection GUID.

## Definition

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

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

## Remarks

A table reference identifies a table collection without holding a direct object reference, which keeps it lightweight and serializable. It stores either a collection name or a collection GUID; [TableReference.ReferenceType](/engine/6000.7/script-reference/unity/localization/tablereference/referencetype.md) reports which form is in use, and [TableReference.IsEmpty](/engine/6000.7/script-reference/unity/localization/tablereference/isempty.md) is `true` when neither is set. Assign one implicitly from a string to reference by name, or call [TableReference.FromGuid](/engine/6000.7/script-reference/unity/localization/tablereference/fromguid.md) to reference by GUID. Name references are convenient in code, while GUID references keep resolving after a collection is renamed. Pair a table reference with a [TableEntryReference](/engine/6000.7/script-reference/unity/localization/tableentryreference.md) to address a single entry, and resolve either against a [ResourceDatabase](/engine/6000.7/script-reference/unity/localization/resourcedatabase.md) or a [ResourceTable](/engine/6000.7/script-reference/unity/localization/resourcetable.md).

Additional Resources: [ResourceTable](/engine/6000.7/script-reference/unity/localization/resourcetable.md), [ResourceDatabase](/engine/6000.7/script-reference/unity/localization/resourcedatabase.md), [TableEntryReference](/engine/6000.7/script-reference/unity/localization/tableentryreference.md), [SharedTableData](/engine/6000.7/script-reference/unity/localization/sharedtabledata.md)

Create references by name and by GUID, then inspect how each identifies its collection.

## Examples

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

namespace Unity.Localization.Samples
{
    public class TableReferenceOverviewExample
    {
        public void Run()
        {
            TableReference byName = "UI Text";                          // implicit conversion from string
            TableReference byGuid = TableReference.FromGuid("6f1e2c0a9b3d4e5f8a1b2c3d4e5f6a7b");

            Debug.Log(byName.ReferenceType);   // Name
            Debug.Log(byGuid.ReferenceType);   // Guid
            Debug.Log(byName.IsEmpty);         // False
        }
    }
}
```

## Properties

| Property                                                                                                                | Description                                                                                        |
| ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [IsEmpty](/engine/6000.7/script-reference/unity/localization/tablereference/isempty.md)                                 | Whether this reference points at nothing.                                                          |
| [ReferenceType](/engine/6000.7/script-reference/unity/localization/tablereference/referencetype.md)                     | How this reference identifies its collection.                                                      |
| [TableCollectionName](/engine/6000.7/script-reference/unity/localization/tablereference/tablecollectionname.md)         | The name of the referenced collection, or null when the reference is empty or GUID-based.          |
| [TableCollectionNameGuid](/engine/6000.7/script-reference/unity/localization/tablereference/tablecollectionnameguid.md) | The GUID of the referenced collection, or an empty GUID when the reference is empty or name-based. |

## Methods

| Method                                                                                          | Description                                          |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| [Equals](/engine/6000.7/script-reference/unity/localization/tablereference/equals.md)           | Checks whether this reference equals another object. |
| [GetHashCode](/engine/6000.7/script-reference/unity/localization/tablereference/gethashcode.md) | Computes a hash code for this reference.             |
| [ToString](/engine/6000.7/script-reference/unity/localization/tablereference/tostring.md)       | Returns a readable string describing this reference. |

## Static Methods

| Method                                                                                    | Description                                                         |
| ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| [FromGuid](/engine/6000.7/script-reference/unity/localization/tablereference/fromguid.md) | Creates a table reference that identifies a collection by its GUID. |

## Operators

| Operator                                                                                           | Description                                                   |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [TableReference](/engine/6000.7/script-reference/unity/localization/tablereference/op-implicit.md) | Converts a collection name into a name-based table reference. |

## Enums

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