|
-
February 10th, 2010, 05:44 PM
#1
Feels like too many If's!
I am developing an app for a mobile device and it feels like I am using way too many If / else statements.
The scenario is I have a number of picture boxes which change colour on being clicked in. I check the coolour of each picture box via the colour whether or not a number is stored into an int array.
i.e:
for (int i = 0; i < 6; i++)
{
if (PictureBox1.BackColor == Color.Red)
{
Number[i] = 1;
}
else if (PictureBox2.BackColor == Color.Red)
{
Number[i] = 2;
}
else if (PictureBox3.BackColor == Color.Red)
{
Number[i] = 3;
}
else if (PictureBox4.BackColor == Color.Red)
{
Number[i] = 4;
}
}
Is there any other way I could go about this? or is this my only bet?
Thanks.
P.S - the if list is a lot bigger than what is pasted here
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|