# LineCollection.GetEnumerator Method

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

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 10.1
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.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 for WPF > Reference > TXTextControl > LineCollection.GetEnumerator Method
- **505 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/linecollection/getenumerator-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/linecollection/getenumerator-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/linecollection/getenumerator-method/llms-full.txt

---

### Description

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

### Syntax

```csharp
public LineCollection.LineEnumerator GetEnumerator();
```

```vbnet
Public Function GetEnumerator() As LineCollection.LineEnumerator
```

### Return Value

The return value is an IEnumerator that represents the collection.

### Examples

The following example works with lines in the current document by using `LineCollection.GetEnumerator`.

```csharp
LineCollection lineCollection = textControl.Lines;
textControl.Text = "Quarterly results\nRevenue increased by 12%.";

IEnumerator enumerator = lineCollection.GetEnumerator();

while (enumerator.MoveNext())
{
    Line line = (Line)enumerator.Current;
    Console.WriteLine(line);
}
```

```vbnet
Dim lineCollection As LineCollection = textControl.Lines
textControl.Text = "Quarterly results" & vbCrLf & "Revenue increased by 12%."

Dim enumerator As IEnumerator = lineCollection.GetEnumerator()

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

---

## Nearby

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