The Random
class generates a pseudorandom sequence of random bytes, integers, or doubles.
To use Random
, you can optionally provide a seed to initiate the random number series.
Using the same seed guarantees the same series of numbers.
using System;
using System.Numerics;
class Sample
{
public static void Main()
{
Random r1 = new Random(1); Random r2 = new Random(1);
Console.WriteLine(r1.Next(100) + ", " + r1.Next(100));
Console.WriteLine(r2.Next(100) + ", " + r2.Next(100));
}
}
The output:
24, 11
24, 11
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |