# SubTextPartCollection.CopyTo Method

> Copies the elements of the collection to an array, starting at a particular index.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 23.0
- **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 > SubTextPartCollection.CopyTo Method
- **773 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/copyto-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/copyto-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/copyto-method/llms-full.txt

---

### Description

Copies the elements of the collection to an array, starting at a particular index.

### Syntax

```csharp
public void CopyTo(Array array, int index);
```

```vbnet
Public Sub CopyTo(array As Array, index As Integer)
```

### Parameters

| Parameter | Description |
|---|---|
| array | Specifies the array to copy to. |
| index | Specifies the index of the destination array at which to begin copying. |

### Examples

The following example copies named regions to a stable array before marking them as reviewed.

```csharp
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
SubTextPartCollection parts = textControl.SubTextParts;
SubTextPart customer = new("CustomerName", 10) { Data = @"{""category"":""customer""}" };
parts.Add(customer);
SubTextPart[] snapshot = new SubTextPart[parts.Count];
parts.CopyTo(snapshot, 0);
foreach (SubTextPart part in snapshot)
{
    part.Data = @"{""reviewed"":true}";
}
```

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim parts As SubTextPartCollection = textControl.SubTextParts
Dim customer As New SubTextPart("CustomerName", 10) With { .Data = "{""category"":""customer""}" }
parts.Add(customer)
Dim snapshot(parts.Count - 1) As SubTextPart
parts.CopyTo(snapshot, 0)
For Each part As SubTextPart In snapshot
    part.Data = "{""reviewed"":true}"
Next
```

---

## Nearby

- **Previous:** [SubTextPartCollection.AddResult Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/addresult-enumeration/llms-full.txt)
- **Next:** [SubTextPartCollection.Count Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/subtextpartcollection/count-property/llms-full.txt)
