Cloudmersive

How to Validate a Street Address in C# .NET Framework

Validation of street addresses can save you from all sorts of headaches, especially if you are mailing out items on a regular basis. Normally it’s quite complicated to set up a proper address verification system, but today we are going to employ an API designed for the task. This will allow us to skip all the hard work and be done in a couple minutes.

Begin with installation of our client via NuGet.

Install-Package Cloudmersive.APIClient.NET.Validate -Version 2.0.7

Now call our function, like so:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.Validate.Api;using Cloudmersive.APIClient.NET.Validate.Client;using Cloudmersive.APIClient.NET.Validate.Model;namespace Example{public class AddressValidateAddressExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new AddressApi();var input = new ValidateAddressRequest(); // ValidateAddressRequest | Input parse requesttry{// Validate a street addressValidateAddressResponse result = apiInstance.AddressValidateAddress(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling AddressApi.AddressValidateAddress: " + e.Message );}}}}

Then enter in an address to test out. If the address is valid, the API will let you know, as well as provide global coordinates for its location.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.