# SubTextPart Constructor

> Initializes a new instance of the SubTextPart class.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Constructor
- **Introduced:** 23.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 > SubTextPart Constructor
- **940 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/subtextpart/constructor/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/subtextpart/constructor/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/subtextpart/constructor/llms-full.txt

---

### Description

Initializes a new instance of the SubTextPart class.

### Syntax

#### SubTextPart(string, int)

Creates a subtextpart with the specified name and/or id. The start and length of the subtextpart are initialized to zero. When a zero-length subtextpart is inserted, the current text selection defines it position and length.

```csharp
public SubTextPart(string name, int id);
```

```vbnet
Public Sub New(name As String, id As Integer)
```

| Parameter | Description |
|---|---|
| name | Specifies the name of the subtextpart. This parameter can be null or an empty string to indicate, that the subtextpart has no name. |
| id | Specifies an identifier for the subtextpart. This parameter can be 0 to indicate, that the subtextpart has no identifier. |

#### SubTextPart(string, int, int, int)

Creates a subtextpart with the specified name, id, start position and length.

```csharp
public SubTextPart(string name, int id, int start, int length);
```

```vbnet
Public Sub New(name As String, id As Integer, start As Integer, length As Integer)
```

| Parameter | Description |
|---|---|
| name | Specifies the name of the subtextpart. This parameter can be null or an empty string to indicate, that the subtextpart has no name. |
| id | Specifies an identifier for the subtextpart. This parameter can be 0 to indicate, that the subtextpart has no identifier. |
| start | Specifies the index (one-based) of the first character which belongs to the subtextpart. |
| length | Specifies the number of characters which belong to the subtextpart. |

### Examples

The following example marks the selected customer name as a named document region.

```csharp
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
SubTextPart subTextPart = new("CustomerName", 10);
textControl.SubTextParts.Add(subTextPart);
```

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim subTextPart As New SubTextPart("CustomerName", 10)
textControl.SubTextParts.Add(subTextPart)
```

---

## Nearby

- **Previous:** [SubTextPart Class](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/subtextpart/llms-full.txt)
- **Next:** [SubTextPart.Data Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/subtextpart/data-property/llms-full.txt)
