C#枚举类型用于标志位,可以进行与和或操作
enum Mammalia { Bison = 1, Human = 2, Mammal = 255 } public class MammalCheck { public static void Main( ) { //Mammalia pattern = Mammalia.Mammal; Mammalia pattern = Mammalia.Bison | Mammalia.Human; Mammalia animal = Mammalia.Bison; if ( (pattern & animal) != 0) { Console.WriteLine ("{0} is a member of ({1}).", animal, pattern); } } }