D
David Sworder
With a standard enum, values are automatically assigned.
public enum MyEnum{Happy,Sad,Angry,Grandpa};
....but what about a bitflag enum?
[Flags()]
public enum MyEnum:int{
FalseTeeth=0x00000001
BrainCancer=0x00000002
CronesDisease=0x00000004
AllDiseasesAndProblems=0xffffffff
}
In this example, is it necessary for me to manually assign the values to
'FalseTeeth', 'BrainCancer', and 'CronesDisease' or does the compiler do
this for me automatically? For small enums, I don't really mind the
inconvenience of manually typing the associated bitvalues. However, it's
more of a pain for larger enums -- especially when I need to insert an item
in the enum at some later time and all of the bitflag values must be
adjusted.
public enum MyEnum{Happy,Sad,Angry,Grandpa};
....but what about a bitflag enum?
[Flags()]
public enum MyEnum:int{
FalseTeeth=0x00000001
BrainCancer=0x00000002
CronesDisease=0x00000004
AllDiseasesAndProblems=0xffffffff
}
In this example, is it necessary for me to manually assign the values to
'FalseTeeth', 'BrainCancer', and 'CronesDisease' or does the compiler do
this for me automatically? For small enums, I don't really mind the
inconvenience of manually typing the associated bitvalues. However, it's
more of a pain for larger enums -- especially when I need to insert an item
in the enum at some later time and all of the bitflag values must be
adjusted.