ASP.NET Conditional Statements - SnippetGood most recent 30 from http://snippetgood.com2010-07-29T23:59:54Zhttp://snippetgood.com/feeds/question/107http://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://snippetgood.com/questions/107/asp-net-conditional-statementsASP.NET Conditional StatementsTillimook2009-10-17T15:52:33Z2009-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
<statements>
Else If condition Then
<statements>
</code></pre>
<p>Thank you.</p>
http://snippetgood.com/questions/107/asp-net-conditional-statements/108#108Answer by miss snippet for ASP.NET Conditional Statementsmiss snippet2009-10-17T16:29:01Z2009-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>