C# random number question

Drew

Client
Регистрация
29.07.2012
Сообщения
70
Благодарностей
14
Баллы
8
Anyone have a simple way to get random number between a range in c#.

GetRandomeNumber Class is not working.
 

alex61

Client
Регистрация
20.06.2012
Сообщения
22
Благодарностей
4
Баллы
3
I use this way

public static int GetRandomNumber(int min, int max)
{
return min + BitConverter.ToInt32(Guid.NewGuid().ToByteArray(),4) % (max-min+1);
}
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
  • Спасибо
Реакции: pyk

alex61

Client
Регистрация
20.06.2012
Сообщения
22
Благодарностей
4
Баллы
3
But there is one issue for rnd.Next. If you want to generate for example 10000 random numbers in one loop then you'll get the similar number or similar groups of numbers.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)