看板 C_Sharp 關於我們 聯絡資訊
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