![]()
A 32-bit signed integer greater than or equal to zero and less than int.MaxValue.
Random.Next generates a random number whose value ranges from zero to less than int.MaxValue. To generate a random number whose value ranges from zero to some other positive number, use the Random.Next(int) method overload. To generate a random number within a different range, use the Random.Next(int, int) method overload.
The following example demonstrates using the Next method. The output generated by this example will vary.
C# Example
using System;
class RandomTest {
public static void Main() {
Random rand1 = new Random();
for (int i = 0; i<10;i++)
Console.WriteLine("The random number is {0}",rand1.Next());
}
}
The output is
The random number is 1544196111