Random Number Generator in C#
In some situations we have to generate Random numbers in our applications for different purposes. In these situations we have to use Random Class in C# for generating the Random numbers. The Random Class in C# represents a pseudo-random number generator, a device that produces a sequence of numbers that meet certain statistical requirements for randomness.
The Next() method in Random class returns a nonnegative random number.
We can limit the generation of Random number by giving a specified range to Next() method.
The above code limit to generate the Random number within the specified range from 10 to 20.
To improve performance, create one Random object to generate many random numbers over time, instead of repeatedly creating a new Random objects to generate one random number.