Results 1 to 2 of 2

Thread: Random Numbers

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207

    Random Numbers

    In VB if one wanted to create a random number between a range one could to this:
    VB Code:
    1. CInt((2 - 1 + 1) * Rnd() + 1)

    Does anyone know how to go about this in c#.

    Thanks
    Jeremy

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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());
    	}
    
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width