Enum定义位域, 即可以通过位操作来产生未命名的值

通过FlagsAttribute可以实现。

// A bit field or flag enumeration of harvesting seasons.
[Flags]
public enum Seasons
{
    None = 0,
    Summer = 1,
    Autumn = 2,
    Winter = 4,
    Spring = 8,
    All = Summer | Autumn | Winter | Spring
}

Seasons sa = Seasons.Summer | Seasons.Autumn;

posted @ 2013-07-04 09:16  muzizongheng  阅读(339)  评论(0编辑  收藏  举报
如果我们时时忙着展现自己的知识, 将何从忆起成长所需的无知?