GeoLocation.Data
1.0.1
dotnet add package GeoLocation.Data --version 1.0.1
NuGet\Install-Package GeoLocation.Data -Version 1.0.1
<PackageReference Include="GeoLocation.Data" Version="1.0.1" />
<PackageVersion Include="GeoLocation.Data" Version="1.0.1" />
<PackageReference Include="GeoLocation.Data" />
paket add GeoLocation.Data --version 1.0.1
#r "nuget: GeoLocation.Data, 1.0.1"
#:package GeoLocation.Data@1.0.1
#addin nuget:?package=GeoLocation.Data&version=1.0.1
#tool nuget:?package=GeoLocation.Data&version=1.0.1
GeoLocation.Data
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 GeoLocation.Data
Targets net10.0.
Quick start
using GeoLocation.Data;
var geo = new GeoLocationService();
// 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, ...
API
GeoLocationService
| 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. |
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)"
StateβId,Name,CitiesCityβId,Name
| 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 (1)
Showing the top 1 NuGet packages that depend on GeoLocation.Data:
| Package | Downloads |
|---|---|
|
CountryPicker.Blazor
A lightweight, high-performance, and beautifully styled CountryPicker component for Blazor, ported from the popular country_picker Flutter package by Daniel Ioannou. Features searchable dropdown combobox, customizable favorites, exclusions, and dialing codes, using zero-asset native emoji flags. |
GitHub repositories
This package is not used by any popular GitHub repositories.