如何将枚举和路由传递给采用int的操作? [英] How do I pass enum and route to action that takes int?

查看:75
本文介绍了如何将枚举和路由传递给采用int的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在动作中传递负数,但在地址栏中我不想显示负数。

这个负数是枚举值。

mydomain.com/myprojects/Days/Index/0

mydomain.com/myprojects/Days/Index/-3



我尝试了什么:



目前我传递了enum的负int值

解决方案

< blockquote>我认为你有设计问题,应该摆脱负面的枚举。必要时重构。



否定枚举没有任何好处。我所期望的唯一标准是未知或默认的默认值0。



事实上你甚至需要考虑如何处理它表明它是一个设计错误(来自标准)。


I need to pass negative number in the action but in the address bar i do not want negative number to display.
This negative number is value for an enum.
mydomain.com/myprojects/Days/Index/0
mydomain.com/myprojects/Days/Index/-3

What I have tried:

Currently I am passing negative int value of enum

解决方案

I think you have design issues, and should get rid of the "negative" enums. Refactor if necessary.

There is no advantage to negative enums. The only "standard" I would expect would be a default of "0" for "Unknown" or "Default".

The fact you have to even think about how to handle it shows it's a design error (from the norm).


这篇关于如何将枚举和路由传递给采用int的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆