Shorten this if statement in Razor to one line

前端 未结 4 884
情书的邮戳
情书的邮戳 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:09

    Another way would be:

    @if(SiteMap.CurrentNode.Title == "Contact") { 
    }

    I personally find it more readable than the ternary operator, but this is personal

提交回复
热议问题