Thursday, December 27, 2018

ternary expressions in Razor markup

@if(!String.IsNullOrWhiteSpace(Model.Foo)) { @Model.Foo<text>...</text> }

 
 

Could be rewritten as...

@(!String.IsNullOrWhiteSpace(Model.Foo) ? Model.Foo + "..." : "")

No comments:

Post a Comment