SOSCSRPG icon indicating copy to clipboard operation
SOSCSRPG copied to clipboard

Replace random number generation

Open ScottLilly opened this issue 4 years ago • 0 comments

RNGCryptoServiceProvider is being deprecated. Replace with new technique:

public static int GetNumberBetween(int minimumValue, int maximumValue)
{
    // Need to add one to maximumValue, because otherwise,
    // this function will never generate a value that matches the maximumValue.
    // For example: to get a value from 1 to 10 (inclusive),
    // The code must (effectively) call: RandomNumberGenerator.GetInt32(1, 11);
    return RandomNumberGenerator.GetInt32(minimumValue, maximumValue + 1);
}

ScottLilly avatar Jan 10 '22 19:01 ScottLilly