0

给定以下枚举:

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;

谢谢

4

1 回答 1

5

ValueEmpty是 2 ( ValueOne+1)

valueFour为 3 (2 | 1)(按位或,00100001= 0011

ValueFive是 (2 | 2) 是2(按位或,0010OR 0010= 0010

于 2013-05-26T18:31:12.180 回答