c# random number system code example

Example 1: c# random generator

// One string will be randomly picked and displayed 
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 2: how to generate random numbers in c#

//works in visual studio for unity
int randomNumber = UnityEngine.Random.Range(1, 100);  //Random number between 1 and 99