What I'm trying do is to make program show how many times certain number has been generated. For example, if random number = 1 then +1 in the label displayed, if number 1 generated again then +1 to label which equal to 2 now and etc. Same with two and three, but in my case every time i click button , it would just display 1 in different labels and not display the sum of how many times they have been generated.... For each number i have separate label.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random gen = new Random();
int number = gen.Next(1, 4);
label5.Text = number.ToString();
if (number == 1)
{
int sum = 0;
int count = 1;
sum += count;
label9.Text = sum.ToString();
}
else if (number == 2)
{
int sum = 0;
int count = 1;
sum += count;
label10.Text = sum.ToString();
}
else if (number == 3)
{
int sum = 0;
int count = 1;
sum += count;
label11.Text = sum.ToString();
}
}