# TextPartCollection.GetEnumerator Method

> Returns an enumerator that can be used to iterate through the collection.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 16.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET Server > Reference > TXTextControl > TextPartCollection.GetEnumerator Method
- **475 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textpartcollection/getenumerator-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textpartcollection/getenumerator-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textpartcollection/getenumerator-method/llms-full.txt

---

### Description

Returns an enumerator that can be used to iterate through the collection.

### Syntax

```csharp
public TextPartCollection.TextPartEnumerator GetEnumerator();
```

```vbnet
Public Function GetEnumerator() As TextPartCollection.TextPartEnumerator
```

### Return Value

The return value is an IEnumerator that represents the collection.

### Examples

The following example works with text parts in the current document by using `TextPartCollection.GetEnumerator`.

```csharp
TextPartCollection textPartCollection = textControl.TextParts;

IEnumerator enumerator = textPartCollection.GetEnumerator();

while (enumerator.MoveNext())
{
    object item = (object)enumerator.Current;
    Console.WriteLine(item);
}
```

```vbnet
Dim textPartCollection As TextPartCollection = textControl.TextParts

Dim enumerator As IEnumerator = textPartCollection.GetEnumerator()

While enumerator.MoveNext()
    Dim item As Object =
        DirectCast(enumerator.Current, Object)
    Console.WriteLine(item)
End While
```

---

## Nearby

- **Previous:** [TextPartCollection.Count Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textpartcollection/count-property/llms-full.txt)
- **Next:** [TextPartCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textpartcollection/getitem-method/llms-full.txt)
