---
title: "Format an Irish address with an Eircode in C#"
url: https://recursiveai.org/onecontact/cookbook/format-irish-postal-address-with-eircode/
description: "Turn a comma-separated Irish address into a mailing label in C#. Put the county on its own line and insert the space in a seven-character Eircode."
version: "1.0.0"
---

# Format an Irish address with an Eircode in C#

**OneContact** is a free, open-source contact data library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies, no network access.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneContact) · [GitHub](https://github.com/recursive-ai-oss/onecontact-csharp) · [Docs](https://recursiveai.org/onecontact/docs/) · [Download example (.zip)](https://recursiveai.org/onecontact/cookbook/format-irish-postal-address-with-eircode/format-irish-postal-address-with-eircode.zip)

An Eircode is an Irish postal code.

```shell
dotnet add package RecursiveAI.OneContact
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneContact;
var address = PostalAddress.Parse(
    "Sample Studio, 12 Example Road, " +
    "Macroom, Co. Cork, t37f8hk",
    Region.Parse("IE"));
Console.WriteLine(
    address.ToString(AddressStyle.Postal));
```

Unzip [the example](https://recursiveai.org/onecontact/cookbook/format-irish-postal-address-with-eircode/format-irish-postal-address-with-eircode.zip), then `dotnet run`.

Prints this mailing label:

```text
Sample Studio
12 Example Road
MACROOM
CO. CORK
T37 F8HK
```

`Region.Parse("IE")` selects Ireland. If OneContact can’t parse the text as an address, `PostalAddress.Parse` throws `ContactParseException`. The example uses an illustrative address: formatting doesn’t establish that the Eircode belongs to the address or that mail can be delivered there.

## Variations

**Add the country for mail sent from abroad.** Replace the final `Console.WriteLine` with this call. It adds `IRELAND` below the Eircode.

```csharp
Console.WriteLine(address.ToString(
    AddressStyle.Postal, includeCountry: true));
```

## Related recipes

- [Format a postal address](https://recursiveai.org/onecontact/cookbook/format-postal-address/)
- [Diagnose an undetermined address country in C#](https://recursiveai.org/onecontact/cookbook/diagnose-ambiguous-postal-address/)

## The short answer

Pass the pasted address to `PostalAddress.Parse` with `Region.Parse("IE")`, then call `ToString(AddressStyle.Postal)`. In the example, the commas separate the addressee, street, town, county, and Eircode. The output puts them on separate lines and changes `t37f8hk` to `T37 F8HK`. There’s no need to split the input at commas or insert the Eircode space yourself.

## How do you format an Irish address?

Put the recipient first, then the house number or name and the street or townland, followed by the postal locality and the county if it’s part of the address. In the [Irish address rules](https://recursiveai.org/onecontact/docs/address-rules-tier2-b/), `Co.` or `County` above the Eircode marks the county. The example prints `MACROOM` above `CO. CORK` and keeps the `CO.` abbreviation. Follow the supplied postal address: [An Post notes](https://www.anpost.com/Post-Parcels/Sending/Correct-Address) that the postal county can differ from the geographic county and that Dublin postal district numbers should be included where applicable.

An Post puts the Eircode last on domestic mail and second to last on mail from abroad, above the country. Leave `includeCountry` at its default for the domestic label in the example; use `true` when the destination country needs a line of its own.

## What is the format of an Irish Eircode?

There are seven characters, written as three characters, a space, and four characters. `T37 F8HK` is the form shown in the [UPU’s Ireland addressing sheet](https://www.upu.int/UPU/media/upu/PostalEntitiesFiles/addressingUnit/irlEn.pdf). Keep the Eircode as text, not a number. OneContact can read the unspaced input above and insert the space for the label; it does not fill in characters that were never supplied.

## How do you find an Eircode for an address in Ireland?

Use [An Post’s address lookup](https://www.anpost.com/Post-Parcels/Sending/Correct-Address) when the Eircode is missing or you need to check that it matches the address. OneContact formats the address and Eircode you supply using local rules. It does not query an address database, find a missing Eircode, or replace your postal county with one inferred from a map.
