【发布时间】:2015-10-03 03:38:23
【问题描述】:
我需要了解一点代码,请任何有运营经验的人,我有一个开源代码,我需要了解这部分:
public static bool ContainsDestroyWholeRowColumn(BonusType bt)
{
return (bt & BonusType.DestroyWholeRowColumn)
== BonusType.DestroyWholeRowColumn;
}
BonusType 是一个枚举:
[Flags]
public enum BonusType
{
None,
DestroyWholeRowColumn
}
请解释一下这部分是如何工作的?
返回 (bt & BonusType.DestroyWholeRowColumn) == BonusType.DestroyWholeRowColumn;
为什么不写:return bt == BonusType.DestroyWholeRowColumn;?
提前致谢
【问题讨论】:
-
要么有人在热狗代码,要么枚举中有/将会有更多的值。
标签: c# bitwise-operators logical-operators