作者sheauhei ( )
看板C_Sharp
標題Re: [問題] 棍 快被搞瘋了 Random問題
時間Tue Jun 26 08:45:42 2007
class test1
{
public int [] index;
static Random r = new Random(unchecked((int)DateTime.Now.Ticks));
public test1()
{
index = new int[6];
for (int i = 0; i < index.Length; i++)
index[i] = r.Next(1000000000) % 2;
//index[i] = r.Next(2);
}
}
======
有堅持Random一定要在建構式中呼叫嗎 XD
沒有的話,把他丟到外面去,然後用static宣告就可以了
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.251.192
推 reptile0426:XDDDDD 謝謝 我TRY看看 06/26 15:19
推 liptonbin:請問為什麼要加個static?? 06/27 14:42
推 FantasyRyu:有可能稍稍誤解了static的用法,我是覺得不用加 06/27 16:51
推 diamondking:請搜尋RNGCryptoServiceProvider類別的用法,即可解決 06/29 21:24