Use the below program to generate random number in C#:
class Program
{
static void Main()
{
// ... Create new Random object.
Random r = new Random();
// ... Get three random numbers.
// Always 5, 6, 7, 8 or 9.
Console.WriteLine(r.Next(5, 10));
Console.WriteLine(r.Next(5, 10));
Console.WriteLine(r.Next(5, 10));
}
}
Output
5
7
6