# GetMetadata<T>()

> Returns the first metadata item of the given type.

## Definition

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

```csharp
public T GetMetadata<T>() where T : class, IMetadata
```

### Returns

| Type | Description                                                     |
| ---- | --------------------------------------------------------------- |
| T    | The first item assignable to `T`, or null when none is present. |

### Remarks

Use [MetadataCollection.GetMetadatas](/engine/6000.7/script-reference/unity/localization/metadatacollection/getmetadatas.md) when a target can hold more than one item of the same type.

Read the first comment attached to a collection.

### Examples

```csharp
using Unity.Localization;

namespace Unity.Localization.Samples
{
    public class MetadataCollectionGetMetadataExample
    {
        public string Run(MetadataCollection metadata)
        {
            var comment = metadata.GetMetadata<Comment>();
            return comment?.CommentText;
        }
    }
}
```
