Monday, 2 November 2015

Random Number Generator to Generate Different Numbers

C# Random method is initialized using the clock. That's why it generates same value every time it calls. Here is the solution to generates different numbers:


private static readonly Random random = new Random();
private static readonly object syncLock = new object();

public static int RandomNumber(int min, int max)
{
    // synchronize
    lock (syncLock)
    {
        return random.Next(min, max);
    }
}


No comments:

Setup Windows Local Account without the Internet

During the Windows setup,  On the WiFi screen, press SHIFT + F10  or  FN + SHIFT + F10  This will open the command prompt window with admini...