ASP.NET Conditional Statements - SnippetGood most recent 30 from http://snippetgood.com 2010-07-29T23:59:54Z http://snippetgood.com/feeds/question/107 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://snippetgood.com/questions/107/asp-net-conditional-statements ASP.NET Conditional Statements Tillimook 2009-10-17T15:52:33Z 2009-10-31T16:29:04Z <p>What kind of conditional statements does asp.net have, and how are they coded?</p> <p>I'd like to see both VB and C#.</p> <p>Here's a VB one I use:</p> <pre><code>If condition Then &lt;statements&gt; Else If condition Then &lt;statements&gt; </code></pre> <p>Thank you.</p> http://snippetgood.com/questions/107/asp-net-conditional-statements/108#108 Answer by miss snippet for ASP.NET Conditional Statements miss snippet 2009-10-17T16:29:01Z 2009-10-17T16:29:01Z <p><strong>long version for C#:</strong> (whitespace added for readability )</p> <pre><code>if ( remaining_beatles == 4 ) { reunion = "yes"; } else { reunion = "no"; } </code></pre> <p><strong>ternary operator for C#:</strong> (I haven't done this for a while, so feel free to correct me, fellow snippers!)</p> <pre><code>condition ? /* if true */ : /* if false */ </code></pre> <p>examples:</p> <pre><code>remaining_beatles == 4 ? reunion = "yes" : reunion = "no"; mouth_parts == "full_of_cricket" ? groom(); : eat_more_cricket(); </code></pre> <p>oodles more reading: <a href="http://msdn.microsoft.com/en-us/library/ty67wk28" rel="nofollow">http://msdn.microsoft.com/en-us/library/ty67wk28</a>(VS.80).aspx</p> <p>I think there's also a ternary operator for vb using IIF, but I have less experience with that!</p>