Generate Random Numbers C#

Generate a random integer in C#

1
2
3
4
5
6
7
8
9
private static readonly Random random = new Random();
private static readonly object lock_random = new object();
public static int GetRandomNumber(int min, int max)
{
    lock (lock_random)
    {
        return random.Next(min, max);
    }
}

Leave a Reply