using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
private static Random randy = new Random();
protected void Page_Load(object sender, EventArgs e)
{
}
public void Button_Clicked(object sender, EventArgs e)
{
int count = 7;
for (int i = 1; i < count; i++)
// if (i == count)
{
int myInt = nextNo();
string myNum = String.Format("{0}\t", myInt.ToString());
TextBox1.Text += myNum;
TextBox2.Text = ("These are your numbers fsdjio");
}
}
int nextNo()
{
return randy.Next(1, 45);
}
}
强文
问题是我经常会得到重复的数字。如果数字不相同,有没有办法让循环只进展?感谢
我正在使用for循环和Random类来制作带有6个数字的彩票程序。但是我会经常得到重复的数字。我是否必须对其进行编码,以便整个过程重复进行,直到有六个不同的数字?先感谢这里的第一次海报