Zip2City 3.0.0

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

// Install Zip2City as a Cake Tool
#tool nuget:?package=Zip2City&version=3.0.0

Provides fast, in-memory lookup of the postal service city/state names by zip code. All 50 states, DC, PR, VI, and AE. Data current as of September 28, 2021. No external library dependencies. No external calls.

  • Light-weight (430KB)
  • No external library dependencies
  • No external calls

.GetDefaultCityState(zipcode)

var zipcode = "90210";
var cityAndState = Zip2City.GetDefaultCityState(zipcode);  // returns null when there's no match

var city = cityAndState[0];  // "BEVERLY HILLS"
var state = cityAndState[1];  // "CA"

.GetAllCityStates(zipcode)

var zipcode = "37411";
var citysAndStates = Zip2City.GetAllCityStates(zipcode).ToArray();  // returns IEnumerable<string[]> regardless of whether there is a match

var defaultCity = citysAndStates[0];  // "CHATTANOOGA"
var defaultState = citysAndStates[0][1];  // "TN"
var city2 = citysAndStates[1][0];  // "RIDGESIDE"
var state2 = citysAndStates[1][1];  // "TN"

.GetClosestCityState(zipcode)

var zipcode = "99999";
var cityAndState = Zip2City.GetClosestCityState(zipcode);

var city = cityAndState[0];  // "KETCHIKAN"
var state = cityAndState[1];  // "AK"

.GetClosestCityStates(zipcode)

var zipcode = "37411";
var citysAndStates = Zip2City.GetClosestCityStates(zipcode).ToArray();

var defaultCity = citysAndStates[0];  // "KETCHIKAN"
var defaultState = citysAndStates[0][1];  // "AK"
var city2 = citysAndStates[1][0];  // "EDNA BAY"
var state2 = citysAndStates[1][1];  // "AK"
var city3 = citysAndStates[2][0];  // "KASAAN"
var state3 = citysAndStates[2][1];  // "AK"

.GetRandomCityStateZip()

var randomCityStateZip = Zip2City.GetRandomCityStateZip();  // always returns a valid set of city, state, and zip code.

var city = cityAndState[0];  // "TROY"
var state = cityAndState[1];  // "TX"
var zipcode = cityAndState[1];  // "76579"

.GetRandomCityStateZip(random)

var random = new Random(12345);  // seeding will guarantee the return values
var randomCityStateZip = Zip2City.GetRandomCityStateZip(random);

var city = cityAndState[0];  // "ALBANY"
var state = cityAndState[1];  // "GA"
var zipcode = cityAndState[1];  // "31707"

.AllCityStateZips

var allData = Zip2City.AllCityStateZips
var californiaData = allData.Where(d => d[1] == "CA").ToArray()
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

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
3.0.0 27,751 3/12/2022
2.1.0 3,085 10/9/2021
2.0.0 868 10/7/2021
1.0.3 5,432 10/18/2020

3.0.0
* (BREAKING CHANGE) Ended .NET 2.0 support
* (BREAKING CHANGE) Introduced namespace
* Added .GetClosestCityState(zipcode) and .GetClosestCityStates(zipcode) for the exact or the closest match
* Optimized .GetRandomCityStateZip() implementation
* Added .GetRandomCityStateZip(random) for predictable values
* Added static property to get all data
* Added .NET 6 support