# 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 RefRW<T> Optional(NativeArray<T> componentDataNativeArray, int index)
```

### Parameters

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

### Returns

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