Countries/README.md

57 lines
966 B
Markdown

# 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
```csharp
using Nyanbyte.Countries;
Country pl = CountryCodes.PL.GetCountry();
// use the object
Console.WriteLine(pl.OfficialName == "Poland");
```
or
```csharp
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.
```csharp
using Nyanbyte.Countries;
Country? country = Country.GetFromCallingCode(48);
if(country is null)
{
//handle invalid result
return;
}
// use the object otherwise
Console.WriteLine(pl.OfficialName);
```