c# – 如何使用USPS验证给定的地址?

前端之家收集整理的这篇文章主要介绍了c# – 如何使用USPS验证给定的地址?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想验证给予的地址(地址,城市,州,邮政编码)给USPS并返回结果,如果提供的地址是一个有效的地址.并且如果不是有效地址返回无效地址.

那么我如何在C#.Net中做到这一点.

解决方法

here
///Create a new instance of the USPS Manager class
///The constructor takes 2 arguments,the first is
///your USPS Web Tools User ID and the second is 
///true if you want to use the USPS Test Servers.
USPSManager m = new USPSManager("YOUR_USER_ID",true);
Address a = new Address();
a.Address2 = "6406 Ivy Lane";
a.City = "Greenbelt";
a.State = "MD";

///By calling ValidateAddress on the USPSManager object,///you get an Address object that has been validated by the
///USPS servers
Address validatedAddress = m.ValidateAddress(a);

猜你在找的C#相关文章