鉴于以下枚举:
enum MyEnum
{
ValueOne = 1,
ValueEmpty,
ValueTwo = 2,
ValueThree = 2,
ValueFour = ValueOne | ValueEmpty,
ValueFive = ValueTwo | ValueThree
}
ValueFour和ValueFive元素中涉及的操作是什么,因为这些是我得到的值?
//Is assigned 3
var valueOne = (int) MyEnum.ValueFour;
//Is assigned 2
var valueTwo = (int)MyEnum.ValueFive;
由于
答案 0 :(得分:5)
ValueEmpty
为2(ValueOne
+1)
valueFour
是3(2 | 1)(按位或,0010
或0001
= 0011
)
ValueFive
是(2 | 2),2
(按位或,0010
或0010
= 0010
)