C# WinForm: How to Generate two bit random number

Just copy it directly
#region Generate a 2-digit random number
public double NextDouble(Random ran, double minValue, double maxValue, int decimalPlace)
{
double randNum = ran.NextDouble() * (maxValue – minValue) + minValue;
return Convert.ToDouble(randNum.ToString(“f” + decimalPlace));
}
#endregion

Example: Take a random number directly from 70-90 each time
Random ran = new Random();
NextDouble(ran,70,90,2);

Similar Posts: