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

---

### Description

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

### Syntax

```csharp
public CommentCollection.CommentedTextEnumerator GetEnumerator();
```

```vbnet
Public Function GetEnumerator() As CommentCollection.CommentedTextEnumerator
```

### Return Value

The return value is an IEnumerator that represents the collection.

### Examples

The following example works with comments in the current document by using `CommentCollection.GetEnumerator`.

```csharp
CommentCollection commentCollection = textControl.Comments;
textControl.Text = "Payment is due within 30 days.";
textControl.Select(0, textControl.Text.Length);
commentCollection.Add(new CommentedText("Verify the payment term."));

IEnumerator enumerator = commentCollection.GetEnumerator();

while (enumerator.MoveNext())
{
    CommentedText commentedText = (CommentedText)enumerator.Current;
    Console.WriteLine(commentedText);
}
```

```vbnet
Dim commentCollection As CommentCollection = textControl.Comments
textControl.Text = "Payment is due within 30 days."
textControl.Select(0, textControl.Text.Length)
commentCollection.Add(New CommentedText("Verify the payment term."))

Dim enumerator As IEnumerator = commentCollection.GetEnumerator()

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

---

## Nearby

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