比实际需要更感兴趣...是否可以在C#或VB.NET中自动减少枚举?
public enum testEnum
{
this = -1,
that,
other,
}
Run Code Online (Sandbox Code Playgroud)
这样那= -2和其他= -3.
我很确定这样做的唯一方法是专门指定"那个"和"其他",但我想知道是否有自动方式.
编辑
要清楚,我只是在谈论值的自动赋值,而不是枚举减少的实际值.
不,这是不可能的.
如果您愿意,您必须声明值,或者撤销声明:
public enum testEnum
{
other = -3,
that,
@this
}
Run Code Online (Sandbox Code Playgroud)