---
title: "Format a phone number for dialing abroad in C#"
url: https://recursiveai.org/onecontact/cookbook/format-phone-number-for-dialing-abroad/
description: "Use OneContact to format the same UK phone number for dialing from the US and Germany. See when to use a caller-specific prefix instead of a plus sign."
version: "1.0.0"
---

# Format a phone number for dialing abroad 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-phone-number-for-dialing-abroad/format-phone-number-for-dialing-abroad.zip)

Use `FormatOutOfCountry` to get the prefix for the caller’s region: `011` from the US or `00` from Germany for this UK number.

```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 phone = PhoneNumber.Parse(
    "+44 20 7946 0123");
foreach (var from in new[] { "US", "DE" })
{
    var dial = phone.FormatOutOfCountry(
        Region.Parse(from));
    Console.WriteLine($"{from}: {dial}");
}
```

Unzip [the example](https://recursiveai.org/onecontact/cookbook/format-phone-number-for-dialing-abroad/format-phone-number-for-dialing-abroad.zip), then `dotnet run`.

Prints:

```text
US: 011 44 20 7946 0123
DE: 00 44 20 7946 0123
```



The number in the example is from [Ofcom’s range for drama](https://www.ofcom.org.uk/phones-and-broadband/phone-numbers/numbers-for-drama). If a parsed caller region has no metadata, `FormatOutOfCountry` returns the international `+` form rather than guessing a dialing prefix.

## Variations

**Dial the same number from within its own calling-code area.** Add this after the loop:

```csharp
var gb = Region.Parse("GB");
Console.WriteLine(
    phone.FormatOutOfCountry(gb));
```

```text
020 7946 0123
```

**Keep the international form for readers in any region.** Add this after the loop instead:

```csharp
Console.WriteLine(
    phone.Format(PhoneFormat.International));
Console.WriteLine(phone.E164);
```

```text
+44 20 7946 0123
+442079460123
```

## Related recipes

- [Parse a phone number](https://recursiveai.org/onecontact/cookbook/parse-phone-number/)
- [Format a phone number as E.164](https://recursiveai.org/onecontact/cookbook/format-phone-number-e164/)

## The short answer

Parse the destination number once, then call `FormatOutOfCountry` with the region the call originates from. Here `44` is the destination country calling code in both results. Only the prefix before it changes: `011` for a call from the US, `00` for a call from Germany. The formatter produces a string; it doesn’t place a call.

## How do I format a phone number based on the country?

There are two regions to think about. If your input is a national number like `020 7946 0123`, the *destination* region tells the parser how to read it. If the input already begins with `+44`, the country calling code is in the input. Either way, the *caller’s* region goes to `FormatOutOfCountry`. Don’t use the destination region for both steps just because you know it first.

The [formatting rules](https://recursiveai.org/onecontact/docs/phones/) prefer a region’s designated international prefix when it has one. Otherwise, OneContact uses a single plain prefix when available and falls back to international format when it can’t select one. Inside the same calling-code area, the formatter returns national format; inside the North American Numbering Plan it puts `1` before the national format. This is region-based formatting, not a test of whether a carrier or phone can connect the call.

## How do I format my phone number for international use?

If you’re publishing a number for readers in several countries, use `PhoneFormat.International`. It keeps the `+` instead of assuming everyone uses `011` or `00`. For a compact value in your contact database, `E164` keeps the `+`, country calling code and national digits without spaces. Keep an extension separately if you need it. Generate a caller-specific string only when you know the calling region and want to show the prefix used there.
