Random

Mar 22 2005 5:18 PM
I am trying to create a random int. But i do not want to use an array is that possible?

Answers (1)

0
jcity444

jcity444

  • 0
  • 286
  • 0
Mar 23 2005 12:13 AM
Just use the Random class as shown below: static void Main(string[] args) { // // TODO: Add code to start application here // // seed with the current datetime in ticks Random randomNumerGenerator = new Random((int) DateTime.Now.Ticks); // random number between 0 and 200 int randomNumber = randomNumerGenerator.Next(201); Console.WriteLine("The next random number is {0}.", randomNumber); Console.WriteLine("The next random number is {0}.", randomNumerGenerator.Next(201)); Console.WriteLine("The next random number is {0}.", randomNumerGenerator.Next(201)); Console.WriteLine(); Console.WriteLine("Hit Enter to Continue..."); Console.ReadLine(); } -Mike G.