.NET Country Data Lib
src/Nyanbyte.Countries | ||
.gitignore | ||
Countries.sln | ||
countrydata.csv | ||
LICENSE.txt | ||
populate.sh | ||
README.md |
Nyanbyte.Countries
A .NET library for country data, including ISO Codes, currencies, and other data associated with countries.
Usage
Fixed countries by ISO 3166-1 alpha2 code enums
using Nyanbyte.Countries;
Country pl = CountryCodes.PL.GetCountry();
// use the object
Console.WriteLine(pl.OfficialName == "Poland");
or
using Nyanbyte.Countries;
Country pl = Country.GetFromCode(CountryCodes.PL);
// use the object
Console.WriteLine(pl.OfficialName == "Poland");
Querying by data
The methods:
GetFromName
GetByCurrency(string)
GetByCurrency(int)
GetFromCallingCode
GetFromTld
do not guarantee results due to potential invalid input. Therefore validation is required.
using Nyanbyte.Countries;
Country? country = Country.GetFromCallingCode(48);
if(country is null)
{
//handle invalid result
return;
}
// use the object otherwise
Console.WriteLine(pl.OfficialName);