Skip to Content
.NET Common Language Runtime Unleashed
book

.NET Common Language Runtime Unleashed

by Kevin Burton
April 2002
Intermediate to advanced content levelIntermediate to advanced
1024 pages
23h 26m
English
Sams
Content preview from .NET Common Language Runtime Unleashed

System.Random

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).

Listing B.15. Random Example
 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")); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Customizing the Microsoft® .NET Framework Common Language Runtime

Customizing the Microsoft® .NET Framework Common Language Runtime

Steven Pratschner

Publisher Resources

ISBN: 0672321246Purchase book