I'm trying to make a simple lottery generator, my random number always returns 0 in all txt boxes. I'd like to put the random number from my array into each text box, This is there code:
public partial class Form1 : Form
{
private int[] randomArray = new int[6];
int Min = 1;
int Max = 60;
Random rand = new Random();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void genBtn_Click(object sender, EventArgs e)
{
foreach (int value in randomArray)
{
rand.Next(Min, Max);
}
boxNum1.Text = randomArray[0].ToString();
boxNum2.Text = randomArray[1].ToString();
boxNum3.Text = randomArray[2].ToString();
boxNum4.Text = randomArray[3].ToString();
boxNum5.Text = randomArray[4].ToString();
boxNum6.Text = randomArray[5].ToString();
}
}
Aucun commentaire:
Enregistrer un commentaire