Answer the question
In order to leave comments, you need to log in
Is there a simple multi-threaded random number generator with a given dimension in C#?
Of those that I found - RandomNumberGenerator ( https://msdn.microsoft.com/ru-ru/library/system.se... , works well, but not quite - it cannot be given a size, so it selects a random number from the entire space int For example, this code will return a number from -2,147,483,648 to 2,147,483,647, and size limiters cannot be selected.
public static int RandomNumber()
{
var bytes = new byte[4];
var rmg = RandomNumberGenerator.Create();
rmg.GetBytes(bytes);
var returnValue = BitConverter.ToInt32(bytes, 0);
Console.WriteLine("" + returnValue);
return returnValue;
}
Answer the question
In order to leave comments, you need to log in
What prevents most to make an intervall? In general, Random is most often from 0 to 1, and fitting into the interval is already subsequent mathematical manipulations that have nothing to do with random - just sugar.
If you want to learn programming yourself, you need to write labs yourself and not look for ready-made solutions.
int RandomNumber(int min, int max)
{
var r = new Random();
return r.Next(min, max);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question