# GetEnumerator()

> Allows traversing the results of the query with foreach without creating GC allocations.

## Definition

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

```csharp
public UQueryState<T>.Enumerator GetEnumerator()
```

### Returns

| Type       | Description                                                               |
| ---------- | ------------------------------------------------------------------------- |
| Enumerator | A UQueryState\<T>.Enumerator instance configured to traverse the results. |
