Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
C# Generator that creates a random Word + Number combination from a dictionary
/// <summary>
/// Class RandomWordGenerator.
/// </summary>
public static class RandomWordGenerator
{
/// <summary>
/// Creates the random word number combination.
/// </summary>
/// <returns>System.String.</returns>
public static string CreateRandomWordNumberCombination()
{
Random rnd = new Random();
//Dictionary of strings
string[] words = { "Bold", "Think", "Friend", "Pony", "Fall", "Easy" };
//Random number from - to
int randomNumber = rnd.Next(2000, 3000);
//Create combination of word + number
string randomString = $"{words[rnd.Next(0, words.Length)]}{randomNumber}";
return randomString;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment