# Optional(NativeArray<T>, int)

> Stores a safe reference to a component from an array of components at the index. If the array is empty stores a null reference.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

```csharp
public static RefRO<T> Optional(NativeArray<T> componentDataArray, int index)
```

### Parameters

**** (\[NativeArray\<T>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The NativeArray of components.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the components.

### Returns

| Type                                                                  | Description                               |
| --------------------------------------------------------------------- | ----------------------------------------- |
| [RefRO\<T>](/engine/7000.0/script-reference/unity/entities/refro1.md) | Read-only optional reference to component |
