CountryStateCityLibrary 1.2.7

dotnet add package CountryStateCityLibrary --version 1.2.7                
NuGet\Install-Package CountryStateCityLibrary -Version 1.2.7                
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="CountryStateCityLibrary" Version="1.2.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CountryStateCityLibrary --version 1.2.7                
#r "nuget: CountryStateCityLibrary, 1.2.7"                
#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 CountryStateCityLibrary as a Cake Addin
#addin nuget:?package=CountryStateCityLibrary&version=1.2.7

// Install CountryStateCityLibrary as a Cake Tool
#tool nuget:?package=CountryStateCityLibrary&version=1.2.7                

A library to fetch countries, states, and cities. You can get the countries, states, and cities list and their details.

Usage:

For Countries:


1. Get all countries:

CountryService countryService = new CountryService();
List<Country> countries = await countryService.GetCountries();
foreach (var country in countries)
{
Console.WriteLine($"ID: {country.CountryId}, Name: {country.CountryName}, PhoneCode: {country.PhoneCode}, Currency: {country.Currency}");
}

Output:

ID: 1, Name: Afghanistan, PhoneCode: 93, Currency: AFN
ID: 2, Name: Aland Islands, PhoneCode: 358, Currency: EUR
ID: 3, Name: Albania, PhoneCode: 355, Currency: ALL
ID: 4, Name: Algeria, PhoneCode: 213, Currency: DZD
ID: 5, Name: American Samoa, PhoneCode: 1, Currency: USD
ID: 6, Name: Andorra, PhoneCode: 376, Currency: EUR

For States:

1. Get all states by Country Id:

StateService stateService = new StateService();
List<State> states = await stateService.GetStatesByCountryId(1);
foreach (var state in states)
{
Console.WriteLine(state.StateId + " " + state.StateName);
}

Output:

3901 Badakhshan
3871 Badghis
3875 Baghlan
3884 Balkh
3872 Bamyan
3892 Daykundi
3899 Farah
3889 Faryab
3870 Ghazni

For Cities:

1. Get all cities by State Id:

CityService cityService = new CityService();
List<City> cities = await cityService.GetCitiesByStateId(3901);
foreach (var city in cities)
{
Console.WriteLine(city.CityId + " " + city.CityName);
}

Output:

52 Ashkasham
68 Fayzabad
78 Jurm
84 Khandud
115 Raghistan
131 Wakhan

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.7 91 12/4/2024
1.2.6 75 12/3/2024
1.2.5 66 12/3/2024
1.2.4 72 12/3/2024
1.2.3 154 12/2/2024
1.2.2 83 11/29/2024
1.2.1 73 11/29/2024
1.2.0 86 11/29/2024
1.1.4 78 11/28/2024
1.1.3 76 11/28/2024
1.1.2 80 11/28/2024
1.1.1 83 11/28/2024
1.1.0 75 11/28/2024
1.0.0 79 11/28/2024