Skip to content

Repository files navigation

NuGet VersionNuGet DownloadsLicense.NET ≥ 2.1GitHub issuesPRs Welcome

Countries.World.Net

Overview

A simple nuget package designed to:

  • Retrieve a list of all countries.
  • Fetch specific details about a country using its identifier.

Features

  1. Get All Countries:

    • Retrieve a read-only list of all available countries, including their names and capitals.
  2. Get Country by ID:

    • Fetch detailed information about a specific country using its unique ID.
  3. Custom Exception Handling:

    • Throws a CountryNotFoundException when an invalid country ID is queried.
  4. Thread-Safe Initialization:

    • Ensures lazy and thread-safe initialization of country data.

Code Example

Here’s how you can use the package to display all countries and details of Afghanistan:

usingWorld.Net;usingWorld.Net.Helpers;Console.WriteLine("All Countries:");varcountries=CountryProvider.GetAllCountries();foreach(varcountryincountries){Console.WriteLine($"Name: {country.Name}, Capital: {country.Capital}");}Console.WriteLine("\nDetails for Afghanistan:");varafghanistan=CountryProvider.GetCountry(CountryIdentifier.AfghanistanId);Console.WriteLine($"Official Name: {afghanistan.OfficialName}, Capital: {afghanistan.Capital}");

Contributors

Thanks to the following people who have contributed to this project:

About

A .NET library for retrieving countries, states, and cities.

Topics

Resources

Stars

13 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages