Saturday, June 20, 2009

how to generate a range of random number with C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rand
{
class Program
{
static void RandomNumber(int min, int max)
{
int x;
Random random = new Random();
for (int i = min; i <= max; i++)
{
x = random.Next(min, max);
Console.WriteLine(x);
}
}

static void Main(string[] args)
{

RandomNumber(36, 60);



}
}
}
N.B: here 36 to 58 is the range