April 2002
Intermediate to advanced
1024 pages
23h 26m
English
This class provides an implementation of a pseudo-random number generator. System.Random makes it easy to generate numbers that are statistically close to random. Listing B.15 shows how to use the Random class (random.cs).
static void Main(string [] args) { Random r = new Random(); for(int i = 0; i < 10; i++) { Console.Write("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} ", r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000"), r.NextDouble().ToString("0.0000")); ... |