1

What kind of conditional statements does asp.net have, and how are they coded?

I'd like to see both VB and C#.

Here's a VB one I use:

If condition Then
<statements>
Else If condition Then
<statements>

Thank you.

flag

2 Answers

1

long version for C#: (whitespace added for readability )

if ( remaining_beatles == 4 ) { reunion = "yes"; }
else { reunion = "no"; }

ternary operator for C#: (I haven't done this for a while, so feel free to correct me, fellow snippers!)

condition ? /* if true */ : /* if false */

examples:

remaining_beatles == 4 ? reunion = "yes" : reunion = "no";

mouth_parts == "full_of_cricket" ? groom(); : eat_more_cricket();

oodles more reading: http://msdn.microsoft.com/en-us/library/ty67wk28(VS.80).aspx

I think there's also a ternary operator for vb using IIF, but I have less experience with that!

link|flag
0

The vb version of the ternary operator (iif) is:

iif(condition, truepart, falsepart)
link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.