Page Stats
Visitor: 162
The random number generator provided by the .NET Framework is implemented via the System.Random class. By default, the parameterless constructor of the Random() class uses the computer's internal system clock to generate its own seed value whereas the parameterized constructor can accept specific seed values from within the allowed range of Int32 integers.
Random rnd = new Random();
int num = rnd.Next(); // return a positive integer number
int num = rnd.Next(50); // return a positive number less than 50
int month = rnd.Next(1, 13); // return a positive number between 1 and 12
int num = rnd.NextDouble(); // return decimal number between 0 and 1