1
I have a code for a dice roller. Then the person will enter in the field the amount of data that will roll and after that the program will run the amount of data and add.
So I made a array to receive this data but I am not able to add them...
Random rnd = new Random();
int dado6lado;
private void button1_Click(object sender, EventArgs e)
{
int d6 = Convert.ToInt32(qtdD6.Text);
int[] qtd6 = new int[d6];
int soma = 0;
//aqui a função vai pegar a quantidade de dados em qtd6.Lenght, rolar e somar na variavel soma e após isso exibir o valor na ultima linha
for (int i = 0; i < qtd6.Length; i++ ) {
//Dado
dado6lados = rnd.Next(1, 7);
soma = dado6lados + qtd6[i] ;
resultadoD6.Text = soma.ToString();
}
}
You can comment line by line what your
for
should do? By the way, assemble the table test that will find the error quickly.– Woss
What’s the big deal? I do not know if you do what you want, but looking over I saw no mistake, except the fact that if someone enters something wrong will burst and have no value in array, what should be there?
– Maniero