开发者

How do you use enum inside switch statement using MVC & razor view engine?

I have a service which returns a Json data structure. One of the properties in the data is an enum value. When the Json is returned inside the client, I'd like it to react to the data returned using a swit开发者_如何转开发ch statement.

I don't want to hard-code the enum values in the javascript, so I tried using case @MyEnum.Value, but the view renders it simply as 'Value'. I need it to output the actual value of the enum for it to work.

How can I get this to work, or alternatively is there a better method for handling this situation?


Try @((int)MyEnum.Value) for getting the value

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜