How to generate many random various numbers?
Found this little peace of code in book and kept it.using System.Security.Cryptography;public static int RandomNumber(int maxvalue){ RandomGenerator random = RandomGenerator.Create(); byte[] r = new byte[1]; random.GetBytes(r); double val = (double)r[0]/byte.MaxValue; ...
Found this little peace of code in book and kept it.
using System.Security.Cryptography;
public static int RandomNumber(int maxvalue)
{
RandomGenerator random = RandomGenerator.Create();
byte[] r = new byte[1];
random.GetBytes(r);
double val = (double)r[0]/byte.MaxValue;
int i = (int)Math.Round(val * maxvalue, 0);
return i;
}
Like I said not exactly my peace of code.
So to whom, thans..