C# Enums with Flags Attribute

后端 未结 4 1055
难免孤独
难免孤独 2021-02-14 09:54

I was wondering if Enums with Flag attribute are mostly used for Bitwise operations why not the compilers autogenerate the values if the enum values as not defined.

For

4条回答
  •  生来不讨喜
    2021-02-14 10:36

    This is a little easier:

    [Flags]
    public enum MyColor
    {
        Yellow = 1<<0,
        Green = 1<<1,
        Red = 1<<2,
        Blue = 1<<3
    }
    

提交回复
热议问题