In VB if one wanted to create a random number between a range one could to this:
VB Code:
CInt((2 - 1 + 1) * Rnd() + 1)
Does anyone know how to go about this in c#.
Thanks
Jeremy
Printable View
In VB if one wanted to create a random number between a range one could to this:
VB Code:
CInt((2 - 1 + 1) * Rnd() + 1)
Does anyone know how to go about this in c#.
Thanks
Jeremy
Check out the Random() class library.
Code:static void Main(string[] args)
{
Random randomNumber = new Random();
for(int i = 0; i < 10; i++)
{
Console.WriteLine("The {0} random number is: " + randomNumber.Next(1, 10), i.ToString());
}
}