Shorten this if statement in Razor to one line

前端 未结 4 910
情书的邮戳
情书的邮戳 2021-02-18 13:08

Can i shorten this to one line? I have tried various ways but can\'t quite get it right.

@if(SiteMap.CurrentNode.Title == \"Contact\")
{
    @:
4条回答
  •  佛祖请我去吃肉
    2021-02-18 14:06

    There might be an even simpler solution but this should work:

    @Html.Raw((SiteMap.CurrentNode.Title == "Contact") ? "
    " : "")

提交回复
热议问题