How to get the gender of a first name using C# in .NET Framework

Cloudmersive
1 min readSep 22, 2019

--

Knowing someone’s gender based on their first name can be very useful indeed. It can of great help in determining a person’s title when composing letters or emails, for example. Today, we will be looking at how to to accomplish this identification in the easiest way possible.

First, install the Validate API client using Package Manager:

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

Now call NameGetGender and provide it with the name and country code (if possible).

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 NameGetGenderExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.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 GetGenderRequest(); // GetGenderRequest | Gender request information
try
{
// Get the gender of a first name
GetGenderResponse result = apiInstance.NameGetGender(input);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling NameApi.NameGetGender: " + e.Message );
}
}
}
}

Your return will include whether it was successful as well as the gender.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet