Implementing a switch statement in a CSHTML page

后端 未结 4 1308
谎友^
谎友^ 2021-02-03 16:32

I\'m trying to do something different. I have a view that contains an Id. Based on the value of the Id I want to change my heading that appears. Something like:

         


        
4条回答
  •  太阳男子
    2021-02-03 17:25

    @{
        String txt;
        switch (id) {
            case "test":
                txt = "Test";
                break;
            case "prod":
                txt = "Prod";
                break;
            default:
                txt = "WTF";
        }
    }
    
    

    @txt Site

    The Most Concise: Less redundant or repetitive code and markup.

提交回复
热议问题