- Joined
- May 10, 2013
- Messages
- 321
- Reaction score
- 59
Ok, so I'm trying to learn C# as I find it interesting. But I came across a little thing.
Here's the code I have now:
How to make it like this but now in C#?:
Obvious the last code doesn't work. I need to know how to apply this method. Anyone can help?
Thanks.
Here's the code I have now:
Code:
string movies = "";
if (checkBox1.Checked)
{
movies += checkBox1.Text + "\r\n";
}
if (checkBox2.Checked)
{
movies += checkBox2.Text + "\r\n";
}
if (checkBox3.Checked)
{
movies += checkBox3.Text + "\r\n";
}
if (checkBox4.Checked)
{
movies += checkBox4.Text + "\r\n";
}
if (checkBox5.Checked)
{
movies += checkBox5.Text + "\r\n";
}
MessageBox.Show(movies);
How to make it like this but now in C#?:
Code:
for (int i = 1; i <= 5; i++) {
if (checkBox[i].Checked) {
movies += checkBox[i].Text + "\r\n";
}
}
MessageBox.Show(movies);
Obvious the last code doesn't work. I need to know how to apply this method. Anyone can help?
Thanks.

