Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 按位'&';接线员_C#_Casting_Hex - Fatal编程技术网

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)。