简体   繁体   中英

How can I validate worldwide postal codes in my .NET code

I am looking for a way to validate worldwide postal codes in my .NET project, and I don't really want to come up and maintain regular expressions for the whole world.

Preferably I would want to pull in a dependency to a library or in the worst case use some web based service (but that would really be a last resort).

Check out PostalCodes.Net package on github.

It support most countries and has a good interface. Here is an example:

var country = CountryFactory.Instance.CreateCountry("PL");
var postalCode = PostalCodeFactory.Instance.CreatePostalCode(country, "44-100");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM