for (int f = 1; f <= 6; f++)
{
textBox{f+11} = (loto[f].ToString());
}
Hi again, I'm trying to learn c# on my own. Sorry for this noobish questions :)
To be more spesific, that's what I want :
A shortcut to write codes like that :
textBox12.Text = loto[1].ToString();
textBox11.Text = loto[2].ToString();
textBox10.Text = loto[3].ToString();
textBox9.Text = loto[4].ToString();
textBox8.Text = loto[5].ToString();
textBox7.Text = loto[6].ToString();
This code is working but i want to write it in a for loop
You can use a dictionary.
Dictionary<int, TextBox> dictionary = new Dictionary<int, TextBox>();
dictionary.Add(1, textbox1);
... // add the other textboxes
// access the dictionary via index
dictionary[f+11] = ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With