The name 'xyz' does not exist in the current context

后端 未结 7 1836
广开言路
广开言路 2020-12-11 13:45

This is probably really basic in C#, but I looked around a lot to find a solution.

In my MVC controller\'s action method, I have an incoming routeid (programid

7条回答
  •  天命终不由人
    2020-12-11 14:01

    the scope of the account type variable is in the { } of the if. you need to declare the variable outside the if to be able to use it after, or even better:

    string accounttype = programid == 0 ? "Membership" : "Program";
    

提交回复
热议问题