How to Validate a Last Name in C# .NET Framework
1 min readJul 15, 2020
Name parsing is a much more complex task than it seems at first. Not only are there millions of different possibilities, but they are constantly changing every day. So rather than try to setup some kind of database referencing system, we shall instead use the power of machine learning to get this done. On top of that, we will do it in just a few minutes by employing an API.
First we will need to grab out package:
Install-Package Cloudmersive.APIClient.NET.Validate -Version 3.0.6
Now for our function:
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 NameValidateLastNameExample{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 NameApi();var input = new LastNameValidationRequest(); // LastNameValidationRequest | Validation request informationtry{// Validate a last nameLastNameValidationResponse result = apiInstance.NameValidateLastName(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling NameApi.NameValidateLastName: " + e.Message );}}}}
And that’s it! Simple.