7 lines
810 B
Plaintext
7 lines
810 B
Plaintext
== Why is this an issue?
|
||
|
||
When you annotate an https://learn.microsoft.com/en-us/dotnet/api/system.enum[Enum] with the https://learn.microsoft.com/en-us/dotnet/api/system.flagsattribute[Flags attribute], you must not rely on the values that are automatically set by the language to the `Enum` members, but you should define the enumeration constants in powers of two (1, 2, 4, 8, and so on). Automatic value initialization will set the first member to zero and increment the value by one for each subsequent member. As a result, you won’t be able to use the enum members with bitwise operators.
|
||
|
||
=== Exceptions
|
||
|
||
The default initialization of `0, 1, 2, 3, 4, ...` matches `0, 1, 2, 4, 8 ...` in the first three values, so no issue is reported if the first three members of the enumeration are not initialized. |