【发布时间】:2014-03-31 06:47:12
【问题描述】:
我遇到过这个问题:What does the [Flags] Enum Attribute mean in C#?
我一直想知道的一件事是,使用公认的answer's example,如果我声明会发生什么:
[Flags]
public enum MyColors
{
Yellow = 1,
Green = 2,
Red = 3,
Blue = 4
}
该示例中的以下步骤会导致错误吗?如果没有,我怎样才能到达 MyColors.Red?
【问题讨论】:
-
题外话:你期望
MyColors.Yellow | MyColors.Blue返回MyColors.Green吗?如果是这样,如果你做对了,你也许可以做到这一点。
标签: c# enum-flags