How to choose a random numer in C# code example
Example 1: c# random int
Random rnd = new Random();
int number = rnd.Next(1, 10);
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: c# generate random int in range
Random r = new Random();
int rInt = r.Next(0, 100);
int range = 100;
double rDouble = r.NextDouble()* range;
Example 4: c# random
Random rnd = new Random();
Byte[] bytes = new Byte[20];
rnd.NextBytes(bytes);
for (int ctr = 1; ctr <= bytes.Length; ctr++) {
Console.Write("{0,3} ", bytes[ctr - 1]);
if (ctr % 10 == 0) Console.WriteLine();
}