Skip to content

wolfnightblack/DotNetRandomNameGenerator

 
 

Repository files navigation

DotNetRandomNameGenerator

Generates random people and place names drawn from freely available US census data.

Join the chat at https://gitter.im/m4bwav/DotNetRandomNameGenerator

Nuget package link

The library contains a stripped down lists of human names from the US Census names list, and a list of place names from another census list. The library allows you to get random first and last names or both and you can get male and female first names. You can also generate random place names as well. To access this functionality create a NameGenerator in namespace RandomNameGenerator, and call one of the functions like GenerateRandomFirstAndLastName(). The functions names describe literally and simply what those functions do.

Typical Usage (generating a person name):

var personGenerator = new PersonNameGenerator();
var name = _personGenerator.GenerateRandomFirstAndLastName();
	
Console.WriteLine(name); //Outputs some random first and last name combination in the format "{first} {last}" example: "Mark Rogers"

Generating a place name:

var placeGenerator = new PlaceNameGenerator();
var name = _personGenerator.GenerateRandomPlaceName();
	
Console.WriteLine(name); //Outputs some random place name, example: "Hoboken"

Male and female first names can be generated with or without a last name

var personGenerator = new PersonNameGenerator();
var name = _personGenerator.GenerateRandomFemaleFirstName();
	
Console.WriteLine(name); //Outputs some random first female name, example: "Jane"

More than one name can be generated at a time. There are a variety of functions that let you choose gender if desired, and the number of names to be produced.

var personGenerator = new PersonNameGenerator();
var numberOfNames = 1;
var names = _personGenerator.GenerateRandomFemaleFirstAndLastName(numberOfNames);
var name = names.First();
	
Console.WriteLine(name); //Outputs some random first and last female name combination in the format "{first} {last}" example: "Rose Jones"

An existing random object can be passed in, rather than generated by the name generator.

var randomObj = new Random(42);
var personGenerator = new PersonNameGenerator(randomObj);
var name = _personGenerator.GenerateRandomFemaleFirstName();
	
Console.WriteLine(name); //Outputs some random first female name using the passed Random obj, example: "Lindsay"

This functionality can also be exercised has an extension method to a random object.

var randomObj = new Random(42);
var name = randomObj.GenerateRandomFemaleFirstName();
	
Console.WriteLine(name); //Outputs some random first female name using the passed Random obj, example: "Lindsay"

About

Random Person or Place Name Generator Library for .net based on Free US Census Data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%