C# Enums: Nullable or 'Unknown' Value?

前端 未结 6 1119
生来不讨喜
生来不讨喜 2020-12-01 07:12

If I have a class with an enum member and I want to be able to represent situations where this member is not defined, which is it better?

a) Declare the

6条回答
  •  既然无缘
    2020-12-01 07:40

    Everything changes if the enum is attributed with [Flags] Attribute.

        [Flags]
        enum FlagsEnum
        {
            None = 0,
            First = 1,
            Second = 2,
            Third = 4,
            FirstAndThird = 5
        }
    

提交回复
热议问题