hi, i think found a bug in C# language. i have tried on C# express edition with SP1 and visual studio 2005 professional. here is:
this is my first code:
Code Snippet
switch (shipComboBox.SelectedIndex)
{
case 0:
weapon1Label.Text = "Canon";
weapon2Label.Text = "Missile";
break;
case 1:
weapon1Label.Text = "Big Laser";
weapon2Label.Text = "Gila";
break;
}
weapon1PictureBox.Image = System.Drawing.Bitmap.FromFile("..\\..\\Ship\\" + shipPic + "W1.jpg");
weapon2PictureBox.Image = System.Drawing.Bitmap.FromFile("..\\..\\Ship\\" + shipPic + "W2.jpg");
--------------------------------------------------------------------------------------------
this is my second code:
Code Snippet
weapon1PictureBox.Image = System.Drawing.Bitmap.FromFile("..\\..\\Ship\\" + shipPic + "W1.jpg");
weapon2PictureBox.Image = System.Drawing.Bitmap.FromFile("..\\..\\Ship\\" + shipPic + "W2.jpg");
switch (shipComboBox.SelectedIndex)
{
case 0:
weapon1Label.Text = "Canon";
weapon2Label.Text = "Missile";
break;
case 1:
weapon1Label.Text = "Big Laser";
weapon2Label.Text = "Gila";
break;
}
nah, you see those codes are the same. but it's only different at ordering only. the first code has a switch at above of weaponPictureBox, and the second the switch at below weaponPictureBox. my first code has good result, no problem. unfortunately my second code has a problem, when i choose shipComboBox.SelectedIndex to 1, the switch doesn't run a case 1. it's only run case 0 forever. i don't know what i'm wrong. can you explain what happened? thanks.
Note: even i tried in C# express edition SP1 and visual studio 2005 professional. it give the same result. and i have tried to change switch to if, same result as well