Talha Majeed

Talha Majeed

  • NA
  • 40
  • 11.2k

If statement alternative to optimize code

May 19 2017 2:55 AM
 
 
 
I can get fare From one city to To another city and selecting One Way , AC using following code
private void button1_Click(object sender, EventArgs e)    
     {   
          if (comboBox1.SelectedIndex == 0 && comboBox2.SelectedIndex == 0 && radioButton1.Checked &&  radioButton3.Checked) 
            {     
            MessageBox.Show("Your Fare is $225");   
            }        
 }
The problem is there will many many if satements incase if there are only 5 citis in combo box. What is the best way to choose different approcach to avoid if satemens.

Answers (3)