Click to See Complete Forum and Search --> : Randomize


RY33
March 16th, 2003, 01:06 PM
How do I do Randomize in C#?

phirestalker
March 16th, 2003, 04:07 PM
you would use System.Random class, you can seed the value to make it more random by using the overloaded constructor Random(int) :) like the current time in seconds for instance. and to return a random value once u have an instance of the class use the Next method ex:

Random rand = new Random();

rand.Next();

or

rand.Next(maxvalue);

or

rand.Next(minvalue, maxvalue);

pareshgh
March 17th, 2003, 04:35 PM
example,
you can instantiate Random class by

Random RA = new Random();
or
Random RA = new Random(15);


and further use to get the new seed

int num = ra.Next();


Paresh