# HeaderFooterCollection.Count Property

> Gets the number of elements contained in the collection.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Property
- **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 > HeaderFooterCollection.Count Property
- **392 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfootercollection/count-property/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfootercollection/count-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfootercollection/count-property/llms-full.txt

---

### Description

Gets the number of elements contained in the collection.

### Syntax

```csharp
public int Count { get; }
```

```vbnet
Public ReadOnly Property Count As Integer
```

### Examples

The following example adds a default header only when the section has no header or footer definitions.

```csharp
HeaderFooterCollection headersAndFooters = textControl.Sections[1].HeadersAndFooters;
if (headersAndFooters.Count == 0)
{
    headersAndFooters.Add(HeaderFooterType.Header);
}
```

```vbnet
Dim headersAndFooters As HeaderFooterCollection = textControl.Sections(1).HeadersAndFooters
If headersAndFooters.Count = 0 Then
    headersAndFooters.Add(HeaderFooterType.Header)
End If
```

### Limitations

Read only.

---

## Nearby

- **Previous:** [HeaderFooterCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfootercollection/copyto-method/llms-full.txt)
- **Next:** [HeaderFooterCollection.GetEnumerator Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfootercollection/getenumerator-method/llms-full.txt)
