日期:2014-05-18 浏览次数:21016 次
class test { Random rnd=null; public test(Random m_Rnd ) { rnd=m_Rnd; } public void Time(){ Console.WriteLine(rnd.Next(200)); } }
------解决方案--------------------
test t1 = new test(); Thread.Sleep(100); test t2 = new test(); Thread.Sleep(100); test t3 = new test();
------解决方案--------------------
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace Cfeibulaqie { class Program { public static void Main(string[] args) { Random _Rnd = new Random(); for (int i = 0; i < 5; i++) { Console.WriteLine(_Rnd.Next(200)); } Console.WriteLine("///////////////////////////////////////////"); test t1 = new test(); Thread.Sleep(300); test t2 = new test(); Thread.Sleep(300); test t3 = new test(); for (int i = 0; i < 5; i++) { t1.Time(); t2.Time(); t3.Time(); } Console.ReadLine(); } class test { Random m_Rnd = new Random(); public void Time() { Console.WriteLine(m_Rnd.Next(200)); } } } }