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}"); }
private static void DoSomethingRandom(GlobalRandom random) { Console.WriteLine(random.Next()); }