I have 10 strings, all named q1,q2,q3, etc.
My question is, on button click, how do I make them cycle and display within a button?
Current code:
private void nButton_Click(object sender, EventArgs e)
{
for (int g = 0; g <= 10; g++)
{
rBox.Text = q(g);
}
}
Clearly q(g) does not cycle appropriately, so I have come to you, Oracles of code, how would I accomplish this?
** Alternatively, if I wanted to remove the for loop, and instead would just want to increment g by one every time until 10, I assume the structure would resemble something like the following:
private void nButton_Click(object sender, EventArgs e)
{
g++
rBox.Text = q(g);
}
However the question persists, how would I cycle through these strings?
EDIT: I've discovered these neat things called Lists, so I simply created a new list with
List<string> questionNumber = new List<string>();
Then add the string
questionNumber.Add(q1);
As lastly display it through the text box with simple incrementation
private void nButton_Click(object sender, EventArgs e)
{
g++;
rBox.Text = questionNumber[g];
}
q1,q2, etc? If you do there is no way to create a loop and loop through them. You would have to use an array, a list, or any other enumerable set.