using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Threading;
namespace testcsharp
{
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();
test t2 = new test();
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));
}
}
}
}
第一个循环能出5个随机数,第二个循环t1,t2,t3出来的数相同。我的目的是要后面那个,也能出来不同的随机数。
大家能帮忙看看吗?
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Threading;
namespace testcsharp
{
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();
test t2 = new test();
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));
}
}
}
}
第一个循环能出5个随机数,第二个循环t1,t2,t3出来的数相同。我的目的是要后面那个,也能出来不同的随机数。
大家能帮忙看看吗?
解决方案 »
- 为何多出一行的数据?
- 使用ADO.net 实体数据模型遇到的问题
- 遇到一个键盘发送奇怪问题
- ***怎么获得SQLServer上的所有用户(包括sa用户),单独查找一个用户又怎么写,谢谢指导!!
- c/s结构中datagrid取得单元格中数据的简单问题,望大家帮忙(在线等)
- ie直接打开是可以,用程序下载下来不能播放?
- 怎样实现TEXTBOX输入,按button1然后在listbox中显示,重复输入能在listbox中换行显示(不能覆盖之前的字符)?
- c# 万能报表
- 有无版权问题呢????
- 哪有vs.net最新版下载啊??
- 怎么打开网络文件或本地文件啊???谢谢!!
- gridcontrol单元格问题
class test
{
Random rnd=null;
public test(Random m_Rnd )
{
rnd=m_Rnd;
}
public void Time(){
Console.WriteLine(rnd.Next(200));
}
}
能不能通过该MAIN函数来实现?
test t1 = new test();
Thread.Sleep(100);
test t2 = new test();
Thread.Sleep(100);
test t3 = new test();原理
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));
}
}
}}