# RenameKey(long, string)

> Renames a key while keeping its id.

## Definition

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

```csharp
public bool RenameKey(long id, string newKey)
```

### Parameters

**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The stable id of the key to rename.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The new key text.

### Returns

| Type                                                          | Description                                                                            |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` when the key was renamed or already had the requested name; otherwise, `false`. |

### Remarks

The key's stable id does not change, so existing translations keyed by id continue to resolve. Returns `false` when the new name is empty, no key uses the id, or another key already uses the new name. Renaming a key to its current name succeeds and makes no change.

Additional Resources: [SharedTableData.AddKey](/engine/6000.7/script-reference/unity/localization/sharedtabledata/addkey.md), [SharedTableData.GetId](/engine/6000.7/script-reference/unity/localization/sharedtabledata/getid.md)

Fix a typo in a key without changing its id.

### Examples

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

namespace Unity.Localization.Samples
{
    public class SharedTableDataRenameKeyExample
    {
        public void Run()
        {
            var sharedData = ScriptableObject.CreateInstance<SharedTableData>();
            long id = sharedData.AddKey("GREETNIG").Id;   // typo

            bool renamed = sharedData.RenameKey(id, "GREETING");

            Debug.Log(renamed);                 // True
            Debug.Log(sharedData.GetKey(id));   // GREETING, same id
        }
    }
}
```
