EarthCountriesInfo 2.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EarthCountriesInfo --version 2.1.0                
NuGet\Install-Package EarthCountriesInfo -Version 2.1.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="EarthCountriesInfo" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EarthCountriesInfo --version 2.1.0                
#r "nuget: EarthCountriesInfo, 2.1.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.
// Install EarthCountriesInfo as a Cake Addin
#addin nuget:?package=EarthCountriesInfo&version=2.1.0

// Install EarthCountriesInfo as a Cake Tool
#tool nuget:?package=EarthCountriesInfo&version=2.1.0                

EarthCountriesInfo

EarthCountriesInfo is an open-source C# class library that provides comprehensive information about countries on planet Earth. Whether you're building educational tools, geographic applications, or simply curious about global diversity, EarthCountriesInfo has you covered!

Features

  • Country Names: Retrieve country names in multiple languages.
  • Country Phone Codes: Access phone codes for each country.
  • Valid Lengths and Formats: Obtain valid phone number lengths and formats (if available).

Installation

To include EarthCountriesInfo in your project, install the NuGet package:

dotnet add package EarthCountriesInfo

Usage

Country Properties

The CountryProperties class provides essential information for each country:

public sealed record CountryProperties(
    Dictionary<LanguageId, string> CountryNames,
    string CountryPhoneCode,
    Dictionary<int, string>? ValidLengthsAndFormat
);
  • CountryNames: A dictionary containing country names in various languages.
  • CountryPhoneCode: The international phone code for the country.
  • ValidLengthsAndFormat (optional): Valid phone number lengths and formats (if available).

Example Usage

using EarthCountriesInfo;
using HumanLanguages;

// Get information for a specific country (e.g., INDIA)
if (Countries.CountryPropertiesDictionary.TryGetValue(CountryIsoCode.IN, out CountryProperties infoAboutIndia))
{
	Console.WriteLine($"Country Name (English): {infoAboutIndia.CountryNames[LanguageId.en]}");
	Console.WriteLine($"Country Phone Code: +{infoAboutIndia.CountryPhoneCode}");

	if (infoAboutIndia.ValidLengthsAndFormat != null)
	{
		foreach (var (length, format) in infoAboutIndia.ValidLengthsAndFormat)
		{
			Console.WriteLine($"Valid Length: {length}, Format: {format}");
		}
	}

}

Contributing

We welcome contributions! If you find a bug, have an idea for improvement, or want to add support for additional countries, please submit an issue or a pull request on GitHub.

GitHub Repository

Visit our GitHub repository for the latest updates, documentation, and community contributions: EarthCountriesInfo GitHub Repository

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE.

Happy coding! 🌎🚀📚

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

NuGet packages (2)

Showing the top 2 NuGet packages that depend on EarthCountriesInfo:

Package Downloads
SMSwitch

Package Description

GeoIpServices

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 195 4 months ago
2.1.0 542 7 months ago
2.0.0 108 7 months ago
1.0.3 107 7 months ago
1.0.0 113 7 months ago