namespace ConsoleApp201
{
internal class Program
{
public static void PurchaseLotteryTicket1(string a)
{
for (int i = 0; i < 3; i++)
{
Console.Write("现在输入的是第{0}注:",i+1);
a += " " + Console.ReadLine();
}
}
public static void PurchaseLotteryTicket2(string a)
{
Random ran = new Random();
for (int i = 0; i < 3; i++)
{
Console.Write("现在是随机产生第{0}注:",i+4);
a += ran.Next(000, 999).ToString("000");
Console.Write(a);
Console.WriteLine();
}
}
static void Main(string[] args)
{
Console.WriteLine("请输入3位数字");
Console.WriteLine();
string number1 = "";
string number2 = "";
Program.PurchaseLotteryTicket1(number1);
Program.PurchaseLotteryTicket2(number2);
Console.ReadLine();
}
}
}
请教一下:为什么第二个循环产生随机数会把上一次的随机数显示到下一次的随机数?