# GetEnumerator()

> Gets an enumerator which allows iteration of the collection. This is typically used implicitly by "foreach".

## Definition

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

```csharp
public readonly IEnumerator<Collider2D> GetEnumerator()
```

### Returns

| Type                                                                                                        | Description                                    |
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
| [IEnumerator\<Collider2D>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1) | An ernumerator used to iterate the collection. |
