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.
<PackageVersion Include="CountryStateCityLibrary" Version="1.2.7" />
                    
Directory.Packages.props
<PackageReference Include="CountryStateCityLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#:package CountryStateCityLibrary@1.2.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CountryStateCityLibrary&version=1.2.7
                    
Install as a Cake Addin
#tool nuget:?package=CountryStateCityLibrary&version=1.2.7
                    
Install as a Cake Tool

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 199 12/4/2024
1.2.6 117 12/3/2024
1.2.5 105 12/3/2024
1.2.4 113 12/3/2024
1.2.3 625 12/2/2024
1.2.2 129 11/29/2024
1.2.1 107 11/29/2024
1.2.0 119 11/29/2024
1.1.4 121 11/28/2024
1.1.3 119 11/28/2024
1.1.2 121 11/28/2024
1.1.1 126 11/28/2024
1.1.0 112 11/28/2024
1.0.0 118 11/28/2024