Blog Archives
IIF in C#
I always find myself referencing my other projects for this one when I jump between languages, so decided to toss it on the web.
Both examples are in the context of ASP .Net, but syntax also applies np to Winforms
In VB:
<asp:label id="lblmessage" runat="server" visible='<%# iif(1=1,"true","false") %>' />
C# Equivalent:
<asp:label id="lblmessage" runat="server" visible='<%# 1 == 1 ? "true" : "false" %>' />