# SectionCollection.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:** 14.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 > SectionCollection.GetEnumerator Method
- **510 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/sectioncollection/getenumerator-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/sectioncollection/getenumerator-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/sectioncollection/getenumerator-method/llms-full.txt

---

### Description

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

### Syntax

```csharp
public SectionCollection.SectionEnumerator GetEnumerator();
```

```vbnet
Public Function GetEnumerator() As SectionCollection.SectionEnumerator
```

### Return Value

The return value is an IEnumerator that represents the collection.

### Examples

The following example works with sections in the current document by using `SectionCollection.GetEnumerator`.

```csharp
SectionCollection sectionCollection = textControl.Sections;
sectionCollection.Add(SectionBreakKind.BeginAtNewPage, -1);

IEnumerator enumerator = sectionCollection.GetEnumerator();

while (enumerator.MoveNext())
{
    Section section = (Section)enumerator.Current;
    Console.WriteLine(section);
}
```

```vbnet
Dim sectionCollection As SectionCollection = textControl.Sections
sectionCollection.Add(SectionBreakKind.BeginAtNewPage, -1)

Dim enumerator As IEnumerator = sectionCollection.GetEnumerator()

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

---

## Nearby

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