HasFlag always returns True

前端 未结 5 648
有刺的猬
有刺的猬 2021-01-06 07:39

There is a way to check if I got a flag in a series of flag?

Example:

[Flags]
Enum TestEnum
{
  ALIVE, DEAD, ALMOSTDEAD, HURT, OTHERS

}
// check if          


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 08:22

    You can use Enum.HasFlag to check for this.

    bool aTest2 = aTest.HasFlag(TestEnum.ALIVE);
    

提交回复
热议问题