FEATURE REQUEST: enum increments specified as an attribute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Would be nice to specify an incremenet or decremenet as an attribute in an
enum so I can for example have the following...

[Increment(2)]
enum SomeEnum
{
A = 0,
B, // 2
C, // 4
D /6
}


or even Powers of 2 for [Flags] and [Base(2)]
so I get...

[Flags]
[Base(2)]
enum SomeEnum
{
A = 0,
B, // 1
C, // 2
D /4
}


Since you are including other lazy coder features in 2.0, how about this
lazy feature too!
 
Would be nice to specify an incremenet or decremenet as an attribute in an
enum so I can for example have the following...

[Increment(2)]
enum SomeEnum
{
A = 0,
B, // 2
C, // 4
D /6
}
How do you propose handling
[Increment(2)]
enum SomeEnum
{
A = 0,
B, //2
C, //4
D=5,
E, // 6, 7, or 8?
F=3,
G, // 5, 8,10, or 12?
}
or even Powers of 2 for [Flags] and [Base(2)]
so I get...

[Flags]
[Base(2)]
enum SomeEnum
{
A = 0,
B, // 1
C, // 2
D /4
}
While this may have SOME merit, more so than the increment, it still has a
few problems. For one, you should extend the flags class to
FlagsAttribute(int base), not add a new attribute. But in cases like:
[Flags(2)]
enum SomeEnum
{
A = 0,
B, //1
C, //2
D=5, //
E, //what should this be, 4, 8?
F=3, //
G, // what about this one?
}

Since you are including other lazy coder features in 2.0, how about this
lazy feature too!

In the end, I think both of these features would make it ALOT harder to use
and understand enums, I don't see much point in them.
 
Back
Top