# GetVariable(int)

> Retrieves a variable declared in the graph by index.

## Definition

* **Type:** Method
* **Namespace:** [Unity.GraphToolkit.Editor](/engine/6000.7/script-reference/unity/graphtoolkit/editor.md)
* **Assembly:** UnityEditor

```csharp
public IVariable GetVariable(int index)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the variable to retrieve.

### Returns

| Type                                                                                | Description                                                                                                     |
| ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [IVariable](/engine/6000.7/script-reference/unity/graphtoolkit/editor/ivariable.md) | The [IVariable](/engine/6000.7/script-reference/unity/graphtoolkit/editor/ivariable.md) at the specified index. |

### Remarks

Use this method to access a specific [IVariable](/engine/6000.7/script-reference/unity/graphtoolkit/editor/ivariable.md) from the list of variables declared in the graph. This list does not include variable nodes that reference variables. The index is zero-based and reflects the order in which the variables were created. The index must be within the valid range of the variable list (see: [Graph.VariableCount](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graph/variablecount.md)).
