Countries.Standard 3.0.0

dotnet add package Countries.Standard --version 3.0.0
                    
NuGet\Install-Package Countries.Standard -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Countries.Standard" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Countries.Standard" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Countries.Standard" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Countries.Standard --version 3.0.0
                    
#r "nuget: Countries.Standard, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Countries.Standard@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Countries.Standard&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Countries.Standard&version=3.0.0
                    
Install as a Cake Tool

Countries

A zero-dependency .NET library with strongly-typed, compile-time access to every country in the world.

No JSON files to embed, no HTTP calls, no configuration. Every nation ships as a static property directly on the Country struct — intellisense-complete, AOT-friendly, and always available offline.


✨ Features

  • 247 countries and territories — full UN/ISO dataset baked into the assembly
  • Strongly-typed codesCountryCode (ISO 3166-1 alpha-2) and CountryCodeISO3 (alpha-3) enums, no magic strings
  • Rich metadata per country — common name, official name, capital, TLD, currencies, calling codes, borders, area, landlocked flag, region and sub-region
  • Continent collectionsCountry.Europe, Country.Africa, Country.Asia, Country.Americas, Country.Oceania
  • Fast O(1) lookup by ISO2 or ISO3 code via dictionary
  • Fuzzy search — find a country from a misspelled or partial name using Levenshtein distance
  • Value semanticsCountry is a struct; equality, GetHashCode and ToString work out of the box, usable as dictionary key
  • netstandard2.0 target — compatible with .NET Framework 4.6.1+, .NET Core, .NET 5+, Unity, Xamarin

📦 Installation

dotnet add package Countries

🚀 Quick start

using Countries;

// Direct property access — zero allocation, compile-time safe
Country italy = Country.Italy;
Console.WriteLine(italy.Capital);      // Rome
Console.WriteLine(italy.CountryCode);  // IT
Console.WriteLine(italy.ISO3);         // ITA
Console.WriteLine(italy.Region);       // Europe
Console.WriteLine(italy.Area);         // 301336

// Lookup by ISO2 code
Country de = Country.FromCode(CountryCode.DE);

// Lookup by ISO3 code
Country deu = Country.FromCode(CountryCodeISO3.DEU);

// Parse a string (ISO2 or ISO3, case-insensitive)
Country us = Country.Parse("US");
Country usa = Country.Parse("usa");

// Fuzzy search — tolerates typos
Country fr = Country.Fuzzy("Frace");   // → France
Country jp = Country.Fuzzy("Jaapn");   // → Japan

🌍 Continent collections

// All countries in a continent
foreach (var c in Country.Europe)
    Console.WriteLine($"{c.CommonName} ({c.Capital})");

// LINQ works naturally
var landlocked = Country.Africa.Where(c => c.Landlocked);
var largest    = Country.Americas.MaxBy(c => c.Area);
var euros      = Country.Europe.Where(c => c.Currencies.Contains("EUR"));

Available collections:

Property Countries
Country.Africa 54
Country.Americas 55
Country.Asia 49
Country.Europe 50
Country.Oceania 25
Country.All 247

🔎 Country properties

Property Type Example
CommonName string "Italy"
OfficialName string "Italian Republic"
CountryCode CountryCode CountryCode.IT
ISO3 CountryCodeISO3 CountryCodeISO3.ITA
ISONumeric string "380"
CIOC string "ITA"
Capital string "Rome"
Region string "Europe"
SubRegion string "Southern Europe"
TLD string[] [".it"]
Currencies string[] ["EUR"]
CallingCodes string[] ["39"]
AlternativeSpellings string[] ["IT", "Italian Republic", …]
Borders CountryCodeISO3[] [AUT, FRA, SMR, SVN, CHE, VAT]
Landlocked bool false
Area double 301336.0

Country.Fuzzy(string) normalises the input (strips accents, diacritics, punctuation) and finds the closest match using Levenshtein distance. Results with distance > 3 return Country.Unknown.

Country.Fuzzy("Germny")    // → Germany
Country.Fuzzy("BRASIL")    // → Brazil
Country.Fuzzy("Österreich")// → Austria
Country.Fuzzy("zzzzzzzzz") // → Unknown

⚖️ Value semantics

Country a = Country.FromCode(CountryCode.JP);
Country b = Country.Parse("JPN");

bool same = a == b;           // true — equality by CountryCode
int hash  = a.GetHashCode();  // stable, based on CountryCode
string s  = a.ToString();     // "Japan"

// Usable as dictionary key
var capitals = new Dictionary<Country, string>
{
    [Country.Italy]  = "Rome",
    [Country.France] = "Paris",
};

🧪 Tests

The solution includes a full NUnit test suite (Countries.Tests) with 70 tests covering collections, continent filters, lookup, parse, fuzzy search and equality.

dotnet test

📄 License

MIT — see LICENSE.txt.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Countries.Standard:

Repository Stars
unoplatform/Uno.Samples
A collection of code samples for the Uno Platform
Version Downloads Last Updated
3.0.0 0 5/30/2026
1.0.0 266,204 6/21/2018