Answers for "random number generating same number twice c#"

C#
1

c# two different random numbers

Random random = new Random();
int randomNumber1 = random.Next(0, 300);
int randomNumber2 = random.Next(0, 300);
//...
Posted by: Guest on July-24-2020
0

system.random reuses numbers

//Function to get a random number 
private static readonly Random random = new Random(); 
private static readonly object syncLock = new object(); 
public static int RandomNumber(int min, int max)
{
    lock(syncLock) { // synchronize
        return random.Next(min, max);
    }
}
Posted by: Guest on March-16-2020

Code answers related to "random number generating same number twice c#"

C# Answers by Framework

Browse Popular Code Answers by Language