Decreasing a value in a C # or VB.NET enumeration

More interest than a real need ... is it possible to have an automatically decreasing enum in C # or VB.NET?

public enum testEnum
{
    this = -1,
    that,
    other,
}

So what = -2 and another = -3.

I'm sure the only way to do this is to specifically assign "this" and "other," but I wondered if he had an automatic way to do this.

Edit

To be clear, I'm just talking about automatically assigning a value, not about decreasing the actual value of an enumeration.

+3
source share
1 answer

No, It is Immpossible.

You must declare values ​​if you want to do this, or cancel the declaration:

public enum testEnum
{
    other = -3,
    that,
    @this
}
+7
source

All Articles