Search code examples
asp.net-mvcshorthand-if

Short hand if statement


Is there a shorter version of the following:

Using ASP.NET MVC, this is in the HTML page

<%= IsTrue ? Html.Image("~/images/myimage.gif") : "" %>

I know I'm only really writing 3 extra characters, just wondering if there is something better.


Solution

  • No there is not, the ? operator is itself a short hand for the if else statement.