petak, 5. ožujka 2010.

Short if C# (C#: Conditional Shorthand)

Explanation:
If statement is true use first value else use second value

Short if (Conditional Shorthand) Syntax:
(a==b) ? first_value : second_value ;

Short if Without Else ("Null" Conditional Shorthand):

(a==b) ?? value;

Example:
<asp:Literal EnableViewState="false" runat="server"
Text='<%# (Jezik=="it")? "N" + Convert.ToChar(176):GetResources("lblKapacitet") %>'></asp:Literal>