コード例 #1
0
        public static void WriteRandomNumbers()
        {
            var random = GlobalRandom.GetInstance();

            DoSomethingRandom(random);

            var sameRandom = GlobalRandom.GetInstance();

            DoSomethingRandom(sameRandom);

            var randomsAreTheSame = ReferenceEquals(random, sameRandom);

            Console.WriteLine($"Randoms are the same: {randomsAreTheSame}");
        }
コード例 #2
0
 private static void DoSomethingRandom(GlobalRandom random)
 {
     Console.WriteLine(random.Next());
 }