random name generator c# code example
Example 1: random number generator c#
Random rnd = new Random();
int month = rnd.Next(1, 13);
int dice = rnd.Next(1, 7);
int card = rnd.Next(52);
Example 2: c# random generator
Random rnd = new Random();
string[] secOptions = {"string one", "string two", "string three"};
int randomNuber = rnd.Next(0, 3);
string secText = secOptions[randomNuber];
Console.WriteLine(secText);
Example 3: generate random name c#
private void RandName()
{
string[] maleNames = new string[1000] { "aaron", "abdul", "abe", "abel", "abraham", "adam", "adan", "adolfo", "adolph", "adrian"};
string[] femaleNames = new string[1000] { "abby", "abigail", "adele", "adrian"};
string[] lastNames = new string[1000] { "abbott", "acosta", "adams", "adkins", "aguilar"};
Random rand = new Random(DateTime.Now.Second);
if (rand.Next(1, 2) == 1)
{
FirstName = maleNames[rand.Next(0, maleNames.Length - 1)];
}
else
{
FirstName = femaleNames[rand.Next(0, femaleNames.Length - 1)];
}
}
Example 4: random number generator c#
Random numberGen = new Random();
int amountToOutput = 4;
int minimumRange = 1;
int maximumRange = 20;
for(int i = 0; i < amountToOutput; i++)
{
int randomNumber = numberGen.Next(minimumRange, maximumRange);
Console.WriteLine(randomNumber);
}