代碼如下: 代碼如下: namespace RandomTest { class Program { static void Main(string[] args) { for (int i = 0; i < 100; i++) { Random d = new Random(); Console.WriteLine(d.Next(100)); } } } }
為什么這樣?難道要暫停一下子?于是修改代碼: 代碼如下: namespace RandomTest { class Program { static void Main(string[] args) { for (int i = 0; i < 100; i++) { Random d = new Random(); Thread.Sleep(15); Console.WriteLine(d.Next(100)); } } } }
在網(wǎng)上苦苦搜索了2天,沒(méi)什么幫助,而在CSDN論壇卻很快有人給了解決方法: 代碼如下: namespace RandomTest { class Program { static void Main(string[] args) { Random d = new Random(); for (int i = 0; i < 100; i++) { Console.WriteLine(d.Next(100)); } } } }