المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : else if statement vs switch statement



C# Programming
10-22-2012, 03:04 AM
Hi guys,
how do you convert this to switch statement? i want to compare the cons and pros of switch vs else if statement, i can't sleep last night thinking about this, thank you for your help. http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif

{ int a = int.Parse(textBox1.Text); int b = 10; if (a < b) { MessageBox.Show("a is less than b"); } else if (a > b) { MessageBox.Show("a is greater than b"); } else { MessageBox.Show("a is equal to b"); } }