Generate a Random Integers

The following example demonstrates how to generate a random integer.

Random random = new Random();
int num = random.Next();

Call the Next() method multiple times to get the multiple random numbers, as shown below.

Random random = new Random();

for (int i = 0; i < 4; i++)
{
    Console.WriteLine(random.Next());
}

Comments

Leave a Comment

All fields are required. Your email address will not be published.