CountrySC 1.0.0
See the version list below for details.
dotnet add package CountrySC --version 1.0.0
NuGet\Install-Package CountrySC -Version 1.0.0
<PackageReference Include="CountrySC" Version="1.0.0" />
<PackageVersion Include="CountrySC" Version="1.0.0" />
<PackageReference Include="CountrySC" />
paket add CountrySC --version 1.0.0
#r "nuget: CountrySC, 1.0.0"
#:package CountrySC@1.0.0
#addin nuget:?package=CountrySC&version=1.0.0
#tool nuget:?package=CountrySC&version=1.0.0
<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");
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. |
Properties
CountryβId,Name,States, plus computed properties:CountryCodeβ ISO alpha-2 code, derived from the flag emoji's Unicode codepointsFlagEmojiβ the flag emoji (e.g. πΊπΈ)PhoneCodeβ international dialing code (e.g."1","44")Exampleβ a sample local phone number for the countryDisplayNameβ"United States (US)"TimeZonesβ the country'sTimeZoneEntrylistOfficialLanguagesβ the country's official language name(s)FlagSvgβ raw SVG markup of the country's square flag icon, empty string if unavailable
StateβId,Name,CitiesCityβId,NameTimeZoneEntryβZoneName(IANA identifier),CountryCode, plus computed properties:BaseUtcOffsetβ standard (non-DST) UTC offset, resolved from the local system's time zone databaseCurrentUtcOffsetβ 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.
| Product | Versions 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. |
-
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.