CountrySC 1.2.0

dotnet add package CountrySC --version 1.2.0
                    
NuGet\Install-Package CountrySC -Version 1.2.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="CountrySC" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CountrySC" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="CountrySC" />
                    
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 CountrySC --version 1.2.0
                    
#r "nuget: CountrySC, 1.2.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 CountrySC@1.2.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=CountrySC&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=CountrySC&version=1.2.0
                    
Install as a Cake Tool

<p align="center"> <img src=".github/images/banner.svg" alt="CountrySC - offline Countries, States, Cities for .NET" width="100%" /> </p>

CountrySC

A lightweight .NET library providing a complete, offline dataset of countries, states/provinces, and cities β€” with ISO country codes, flag emojis, and international dial codes derived on the fly. No API calls, no network dependency; the dataset ships embedded (Brotli-compressed) inside the package.

Install

dotnet add package CountrySC

Targets net10.0.

Quick start

using CountrySC;

var geo = new CountrySCService();

// All countries, sorted alphabetically by name
IEnumerable<Country> countries = geo.GetAll();

// Look up a country by its 2-letter ISO code (case-insensitive)
Country? us = geo.GetByCountryCode("US");
Console.WriteLine($"{us!.FlagEmoji} {us.Name} (+{us.PhoneCode})"); // πŸ‡ΊπŸ‡Έ United States (+1)

// States/provinces for a country
IEnumerable<State> states = geo.GetStates("US");

// Cities for a given country + state id
var california = states.First(s => s.Name == "California");
IEnumerable<City> cities = geo.GetCities("US", california.Id);

// Find every country sharing an international dial code
IEnumerable<Country> plusOne = geo.GetByPhoneCode("+1"); // US, CA, ...

// IANA time zones for a country
IEnumerable<TimeZoneEntry> zones = geo.GetTimeZones("US"); // America/New_York, America/Chicago, ...
TimeSpan? offset = zones.First().CurrentUtcOffset;

// Official language(s) for a country
IEnumerable<string> languages = geo.GetLanguages("CH"); // French, German, Italian, Romansh

// Square SVG flag icon for a country (raw markup)
string flagSvg = geo.GetFlagSvg("US");

// Currency details for a country (e.g. United States Dollar, USD, $)
CountryCurrency? currency = geo.GetCurrency("US");

// Capital city of a country
string capital = geo.GetCapitalCity("US"); // Washington, D.C.

// Continent of a country
Continent? continent = geo.GetContinent("US"); // Continent.Americas

// Or via country properties:
string currencyName = us.Currency; // "United States Dollar"
string currencyIso = us.Iso4217;  // "USD"
string currencySymbol = us.Symbol; // "$"
string capitalCity = us.CapitalCity; // "Washington, D.C."
Continent continentProperty = us.Continent; // Continent.Americas

API

CountrySCService

Method Description
GetAll() All countries, sorted alphabetically by name.
GetByCountryCode(string countryCode) Finds a country by ISO 3166-1 alpha-2 code (e.g. "US", "GB", "GR"). Case-insensitive; returns null if not found.
GetByPhoneCode(string phoneCode) Finds all countries matching an e.164 dial code (e.g. "1" or "+1").
GetStates(string? countryCode) States/provinces for a country, sorted alphabetically. Empty if the country code is missing or unknown.
GetCities(string? countryCode, int? stateId) Cities for a given country + state id, sorted alphabetically. Empty if either argument is missing or unknown.
GetTimeZones(string? countryCode) IANA time zones observed in a country (e.g. "America/New_York"). Empty if the country code is missing or unknown.
GetLanguages(string? countryCode) Official language(s) of a country (e.g. "English"). Empty if the country code is missing or unknown.
GetFlagSvg(string? countryCode) Raw SVG markup of a country's square flag icon. Empty string if the country code is missing, unknown, or has no embedded icon.
GetCurrency(string? countryCode) Gets the currency details for a given 2-letter country code. Returns null if the country code is missing or unknown.
GetCapitalCity(string? countryCode) Gets the capital city for a given 2-letter country code. Returns string.Empty if the country code is missing or unknown.
GetContinent(string? countryCode) Gets the continent for a given 2-letter country code. Returns null if the country code is missing or unknown.

Properties

  • Country β€” Id, Name, States, plus computed properties:
    • CountryCode β€” ISO alpha-2 code, derived from the flag emoji's Unicode codepoints
    • FlagEmoji β€” the flag emoji (e.g. πŸ‡ΊπŸ‡Έ)
    • PhoneCode β€” international dialing code (e.g. "1", "44")
    • Example β€” a sample local phone number for the country
    • DisplayName β€” "United States (US)"
    • TimeZones β€” the country's TimeZoneEntry list
    • OfficialLanguages β€” the country's official language name(s)
    • FlagSvg β€” raw SVG markup of the country's square flag icon, empty string if unavailable
    • Currency β€” name of the country's currency (e.g. "United States Dollar")
    • Iso4217 β€” three-letter ISO 4217 currency code (e.g. "USD")
    • Symbol β€” currency symbol (e.g. "$" or "€")
    • CapitalCity β€” capital city of the country (e.g. "Washington, D.C.")
    • Continent β€” continent where the country is located (Africa, Americas, Antarctica, Asia, Europe, Oceania)
  • State β€” Id, Name, Cities
  • City β€” Id, Name
  • CountryCurrency β€” Currency (name of the currency), Iso4217 (three-letter code), Symbol (symbol)
  • TimeZoneEntry β€” ZoneName (IANA identifier), CountryCode, plus computed properties:
    • BaseUtcOffset β€” standard (non-DST) UTC offset, resolved from the local system's time zone database
    • CurrentUtcOffset β€” UTC offset right now, including DST if in effect

Time zone data covers 246 countries/territories (418 zones total). Only IANA zone names are embedded; UTC offsets are resolved live via TimeZoneInfo so they stay correct across DST transitions instead of going stale.

Official language data covers 201 countries/territories. Coverage follows the source article and skips a handful of micro-territories and a few disputed/partially-recognized territories not present in the country dataset.

Currency data covers 250 countries/territories. Sourced from the Geocountries currency database (https://www.geocountries.com/country/currencies).

Capital city data covers 250 countries/territories. Sourced from Worlddata (https://www.worlddata.info/capital-cities.php).

Continent data covers 250 countries/territories. Sourced from Worlddata (https://www.worlddata.info/capital-cities.php).

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 124 8/20/2026
1.1.0 106 8/19/2026
1.0.0 112 8/19/2026