Skip to content

Instantly share code, notes, and snippets.

@abierhaus
Created May 5, 2016 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abierhaus/14730be18a8aa771e050e41dde1da201 to your computer and use it in GitHub Desktop.
Save abierhaus/14730be18a8aa771e050e41dde1da201 to your computer and use it in GitHub Desktop.
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