Use of Multiple Test Expressions in an 'If' Statement

Jul 26 2004 8:27 AM
Can anyone clarify for me please, as to whether you can specify more than one expression in the test part of an 'If' statement. I would like to check for two, or more, conditions in my 'If' statement. In the case the none of the conditions are met, I want the same 'else' statement to be executed. I have tried various techniques: if(test1) _____if(test2) MessageBox.Show("HelloWorld"); else MessageBox.Show("GoodbyeWorld"); if(test1) { _____if(test2) MessageBox.Show("HelloWorld"); } else MessageBox.Show("GoodbyeWorld"); But have have come to the conclusion that I will have to repeat the else part twice, which surely cant be so. In VB you can do the following: If (Test1 = true) Or (Test2 = true) Then _____MessageBox.Show("HelloWorld") Else _____MessageBox.Show("GoodbyeWorld") End If Can someone put me out of my misery, in a kind and gentle way please!

Answers (2)