how to generate a random value in c# code example
Example 1: c# random number
int random_number = new Random().Next(1, 10)
Example 2: c# random number
Random rnd = new Random();
int number = rnd.Next(1, 10);
Example 3: how to generate random numbers in c#
int randomNumber = UnityEngine.Random.Range(1, 100);
Example 4: 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)];
}
}