---
title: "Format a Danish postal address in C#"
url: https://recursiveai.org/onecontact/cookbook/format-danish-postal-address/
description: "Parse a Danish address with a floor and door, then format a postal label with uppercase locality and an optional country line in C#."
version: "1.0.0"
---

# Format a Danish postal address 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-danish-postal-address/format-danish-postal-address.zip)

Format the street, floor and door on the delivery line, followed by the Danish postcode and locality.

```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;
using RecursiveAI.OneContact.Addresses;
using RecursiveAI.OneContact.Addresses.Standardization;

var address = PostalAddress.Parse(
    "Eksempelvej 12, 2. th.\n" +
    "2100 København Ø", Region.Parse("DK"));
Console.WriteLine(address.ToString(
    AddressStyle.Postal,
    AddressLayout.Label,
    includeCountry: true));
```

```text
Eksempelvej 12, 2. th.
2100 KØBENHAVN Ø
DENMARK
```

The program above is the complete `Program.cs` in the download. The address is a made-up example, not a verified delivery point. `Region.Parse("DK")` supplies Denmark explicitly; the four postcode digits alone don’t identify the country.

The parser keeps the floor and door punctuation as supplied; it doesn’t add missing periods or invent an apartment. A successful parse is not confirmation that the address exists.

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

## Variations

Use `Display` to keep the locality’s mixed case, or parse a post-office box instead. This replaces the program above:

```csharp
using RecursiveAI.OneContact;
using RecursiveAI.OneContact.Addresses;
using RecursiveAI.OneContact.Addresses.Standardization;
var address = PostalAddress.Parse(
    "Eksempelvej 12, 2. th.\n" +
    "2100 København Ø", Region.Parse("DK"));
Console.WriteLine(address.ToString(AddressStyle.Display));
var box = PostalAddress.Parse(
    "Postboks 321\n2100 København Ø",
    Region.Parse("DK"));
Console.WriteLine(box.ToString(AddressStyle.Postal));
```

```text
Eksempelvej 12, 2. th.
2100 København Ø
Postboks 321
2100 KØBENHAVN Ø
```

## Related recipes

- [Parse a postal address](https://recursiveai.org/onecontact/cookbook/parse-postal-address/)
- [Format a postal address by country](https://recursiveai.org/onecontact/cookbook/format-postal-address/)

## The short answer

To format a Danish address in C#, parse the input with a Denmark country hint, then call `ToString(AddressStyle.Postal, AddressLayout.Label, includeCountry: true)`. OneContact keeps the delivery line’s street, house number, floor and door, capitalizes the locality, and puts `DENMARK` on a separate final line when requested. The example above supplies its input directly as a string, so it needs no address file or online lookup.

Choose `Postal` for a mailing label and `Display` for a mixed-case address in a user interface. These are two renderings of the same parsed value, not separate address databases. Neither rendering checks whether a mailbox or building exists.

## How do you write a Denmark address?

The street name comes before the house number. A floor or door designation follows the number on that delivery line. The next line contains the postcode, a space, and the locality. For an international label, the country goes beneath those lines. OneContact’s [pinned Danish rules](https://recursiveai.org/onecontact/docs/address-rules-tier2-c-north/) describe the `Postal` form as delivery lines as written, locality in capitals, and a postcode without a country-code prefix.

That preservation matters for apartment addresses. The library does not replace `th.` with an English word or silently change the floor. The [City of Aarhus guide to Danish apartments and addresses](https://international.aarhus.dk/live/housing/renting-a-home/danish-apartments-and-addresses) explains that `st.` means the ground floor, `tv.` means left, and `th.` means right. The floor and door are part of the delivery information, not part of the postcode or city name. Keep them in the input rather than stripping them before parsing.

Use the label layout when you need separate lines for an envelope or shipping label. Don’t replace its line breaks with spaces if the destination expects a multiline postal address.

## Can you provide a sample address for Denmark?

The example input is:

```text
Eksempelvej 12, 2. th.
2100 København Ø
```

The formatted label in the recipe keeps the street line and writes `2100 KØBENHAVN Ø` beneath it. With `includeCountry: true`, `DENMARK` follows on its own line. Without that option, the country line is omitted; use that form when the surrounding application already identifies the destination country.

The box variation uses `Postboks 321` instead of a street and house number. It is a separate example of a delivery line, not an extra line to append to every street address. OneContact’s Danish rules render a box line as `Postboks` followed by its number.

These examples demonstrate formatting, not deliverability. For a real shipment, retain the recipient’s supplied street, floor, door and postal locality and resolve any uncertain details with the recipient.

## Where does the postal code go in a Denmark address?

In the supported Danish form, the postcode has four digits and sits to the left of the locality. Keep the leading zeros of postcodes by treating them as text rather than integers. The country hint belongs in the parse call, not as an extra numeric component.

A bare four-digit postcode cannot establish that an address is Danish. The same broad shape occurs in other countries, and OneContact refuses to guess when the content and the caller provide no country evidence. A `DK-` prefix or an explicit country name can supply evidence; the `Postal` output still writes the Danish postcode without that prefix. If your application already has a country selector, pass that value into parsing instead of asking the postcode to do both jobs.
