How to Generate Random Number in C#/CSharp

How to Generate Random Number in C#/CSharp
Rating: 5 - 1 Votes

How to Generate Random Number in C#/CSharp

To generate a random number in C#/CSharp, we make use of Random class.  You can pass min and max value as parameter to its method called Next which will a generate number.  The generated number will be within a range from min value and less than max value.  This means max value will not be part of randomly generated number. Example is given below.