C# 按位'&';接线员
我需要对类型为C# 按位'&';接线员,c#,casting,hex,C#,Casting,Hex,我需要对类型为uint的值执行位'&'操作 enum MsgType : ulong { Begin = 0x00000001, } unit number= 0x00000002; if (number & MsgType.Begin == MsgType.Begin) //不起作用 它给出了一个错误: Operator '&' cannot be applied on operands of type 'uint' or 'bool' 如何转换它?这似乎是一个问题,使
uint
的值执行位'&'操作
enum MsgType : ulong
{
Begin = 0x00000001,
}
unit number= 0x00000002;
if (number & MsgType.Begin == MsgType.Begin)
//不起作用
它给出了一个错误:
Operator '&' cannot be applied on operands of type 'uint' or 'bool'
如何转换它?这似乎是一个问题,使用括号生成正确的编译器输出 i、 e而不是这个:
if(number&MsgType.Begin==MsgType.Begin)
这样做:
if((number&MsgType.Begin)=MsgType.Begin)
根据这是哪种语言或平台?相关的可能重复使用的语言是C#。不清楚这里应该测试什么。可能(数字!=0)。