C# generate random numbers in a range

 If you want to generate a random nomber in a range than use below function. it has two inputs "min" -  enter min value of your range and "max" - enter max value of your range.

 public static int RandomNumber(int min, int max)
         {
             Random random = new Random();
             return random.Next(min, max);
         }

Here in above function Random is a class. this is exist in .net framework by default. you should only use namespace "using System" for this.

Comments

Popular posts from this blog

C# Copy files from one server to another

Suppress StyleCop SA1600

Telerik Rad Grid Sorting