枚举类型 枚举类型定义了一组符号名称/值配对. 如 private enum Color /* : byte */ { White, // Assigned a value of 0 Red, // Assigned a value of 1 Green, // Assigned a value of 2 Blue, // Assigned a value of 3 Orange, // Assigned a value of 4 } 枚举类型使程序更容易编写.阅读和维护:枚举类型是强类型的:枚…
枚举有个特性叫标志位,使用方法如下 [Flags] enum Foo { a =1, b = 2, c = 4, d = 8 } 每个值需要为2的n次方,保证多个值的组合不会重复. 这样在判断其中一个枚举值c 是否在a,b,c这个范围中就可以简化写法 常规写法如下 var c = Foo.c; if( c == Foo.a || c == Foo.b || c == Foo.c ) { } 因为值为2的n次方,所以可以通过按位相与来得出是否在范围内 var c = Foo.c; if( (c &…
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…