What is the difference between these two enum enums [Flags] (C #)

This is more of a question that I ask to understand, not to find out the problem. Consider the following two:

[Flags]
    public enum Flags
    {
        NONE = 0x0,
        PASSUPDATE = 0x1,
        PASSRENDER = 0x2,
        DELETE = 0x4,
        ACCEPTINPUT = 0x8,
        FADE_IN = 0x10,
        FADE_OUT = 0x20,
        FADE_OUT_COMPLETE = 0x40
    }

[Flags]
    public enum Flags
    {
        NONE = 0x0,
        PASSUPDATE,
        PASSRENDER,
        DELETE,
        ACCEPTINPUT,
        FADE_IN ,
        FADE_OUT,
        FADE_OUT_COMPLETE
    }

If I check something with the help of the last enumeration, sometimes overlapping occurs (I think something seems to be DELETEinterpreted as PASSUPDATE | PASSRENDER, whereas in the first example each record is independent of the other (i.e., it DELETEjust DELETEcannot be proved with combinations of another set of flags).

+3
source share
1 answer

Without explicit numbers, the number of instances increases by 1 each time (even with the specified one [Flags]), so you get:

[Flags]
public enum Flags
{
    NONE = 0x0,
    PASSUPDATE, // = 1
    PASSRENDER,// = 2
    DELETE,// = 3
    ACCEPTINPUT,// = 4
    FADE_IN ,// = 5
    FADE_OUT,// = 6
    FADE_OUT_COMPLETE// = 7
}

(, , , 2)

+12

All Articles