J
Jon Slaughter
This is more of a C++ question but I guess it applies equally well to C#.
Is there a way to declare an enum where the values assigned to the fields is
incremented by something rather than 1.
What I would like to do is create an enum where the varaibles increment by
some formula rather than just 1. I doubt this is possible but it would be
nice
Essentially what I'm having to do is
enum E
{
A = StartValue,
B = 1 * 4 + A,
C = 2 * 4 + A,
D = 3 * 4 + A
}
This is be I'm trying to "oop" some flags that are packed in a specific
way(not under my control but done my microsoft... see
http://msdn2.microsoft.com/en-us/library/ms902086.aspx)
It would just be nicer if I could somehow automatically have the compiler do
the math so
enum E
{
A = StartValue,
B,
C,
D
}
and it give the right values.
I'm sure theres no way to do this but I thought I would ask(I guess I could
write a pre-processor but thats to much work.
Thanks,
Jon
Is there a way to declare an enum where the values assigned to the fields is
incremented by something rather than 1.
What I would like to do is create an enum where the varaibles increment by
some formula rather than just 1. I doubt this is possible but it would be
nice
Essentially what I'm having to do is
enum E
{
A = StartValue,
B = 1 * 4 + A,
C = 2 * 4 + A,
D = 3 * 4 + A
}
This is be I'm trying to "oop" some flags that are packed in a specific
way(not under my control but done my microsoft... see
http://msdn2.microsoft.com/en-us/library/ms902086.aspx)
It would just be nicer if I could somehow automatically have the compiler do
the math so
enum E
{
A = StartValue,
B,
C,
D
}
and it give the right values.
I'm sure theres no way to do this but I thought I would ask(I guess I could
write a pre-processor but thats to much work.
Thanks,
Jon