# GetComponentIndex(Component)

> Retrieves the index of the specified component in the array of components attached to the GameObject.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public int GetComponentIndex(Component component)
```

### Parameters

**** (\[Component]\(/engine/6000.7/script-reference/unityengine/component)): The component to search for.

### Returns

| Type                                                       | Description                                                                 |
| ---------------------------------------------------------- | --------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the specified Component if it exists. Otherwise, returns `-1`. |
