HasFlags always returns true for None (0) value in enum

后端 未结 7 1204
轻奢々
轻奢々 2020-12-10 23:51

This is the enum definition:

[Flags]
enum Animals
{
    None = 0,
    Dog = 1,
    Cat = 2,
    Horse = 4,
    Zebra = 8,
}

Now, given the

7条回答
  •  没有蜡笔的小新
    2020-12-11 00:30

    From MSDN

    The HasFlag method returns the result of the following Boolean expression.

    thisInstance And flag = flag
    

提交回复
热议问题