mardi 24 mars 2015

If - else statement without else

Could someone explain me why the if - else statement works like this and not throw an error or exeption? also if this is intentional in C# could someone explain if there is a diffrence between the 2?



if (comboBox1.SelectedIndex == -1) { }
{
//code
}


rather then using



if (comboBox1.SelectedIndex == -1) { }
else {
//code
}


Since I noticed I accidentally made a if - else statement like the above one in my code after I re-arranged the code to make it more readable.


Aucun commentaire:

Enregistrer un commentaire