C#数据与或运算
定义了一个常量:
private const UInt16 FREEZE	        = 0x0001;
定义了一个变量,并初始化为0
UInt16  m_dwAckInstruction = 0 ;
UInt32  dwPar =0x00;
进行如下运算:
m_dwAckInstruction &= ~FREEZE;
m_dwAckInstruction |= dwPar & FREEZE;
在编译时,运算过程报错,
错误   常量值“-2”无法转换为“ushort”	
错误   无法将类型“uint”隐式转换为“ushort”。存在一个显式转换(是否缺少强制转换?)	
请高手指点,如何进行位运算,这个过程哪里不对,谢谢!
------解决方案--------------------
------解决方案--------------------           UInt16 m_dwAckInstruction = 0;
           UInt32 dwPar = 0x00;
           m_dwAckInstruction = (UInt16)(m_dwAckInstruction & (~FREEZE));
           m_dwAckInstruction = (UInt16)(m_dwAckInstruction | (dwPar & FREEZE));