I'm trying to fill in the positions of a vector with incoming data coming of a TextBox, and do the reading in a ListBox but I'm not getting it. Everything seems to work, but only inserts the last element in all positions of the vector.
Code snippet:
int a = 0, i = 0;
private void okClick(object sender, System.EventArgs e)
{
//a incrementa à cada click do botão
a++;
int[] arr = new int[5];
for (i = 0; i < (arr.Length); i++)
{
arr[i] = Int32.Parse(textBox.Text);
}
//limpa o campo do TextBox a cada novo click do botão
textBox.Clear();
//Quando a recebe o quinto clique imprime.
if (a == 5)
{
for (i = 0; i < arr.Length; i++)
{
listBox.Items.Add(arr[i]);
}
}
}