我现在要手批量生成随机数,可是....
随机数的种子一样,生成的数也就一样,如何才能让他不一样呢???用时间做种子也不行,计算机算的实在是太快了.
有办法解决没?
------解决方案--------------------------------------------------------
//这是一个返回随机数的方法,不知道怎么写才好.
就一句代码的事,不要用什么方法!
直接在在类中放一个Random成员变量
public Random m_random = new Random();
使用时直接调用m_random.Next即可
------解决方案--------------------------------------------------------
随机数
string[] ArrColor = { "#1 ", "#2 ", "#3 ", "#4 ", "#5 ", "#6 ", "#7 ", "#8 ", "#9 ", "#11 ", "#12 ", "#13 ", "#14 ", "#15 ", "#16 ", "#17 ", "#18 ", "#19 " };
for (int i = 0 ; i < 10 ; i++)
{
Random rnd = new Random(i*unchecked((int)DateTime.Now.Ticks));
int r2 = rnd.Next(0, ArrColor.Length);
Response.Write( " <li> "+ArrColor[r2]);
}