我想取一个字节的前4位和另一个位的所有位并将它们附加到彼此。
这是我需要达到的效果:将字节的一部分追加到另一个字节
这是我现在有:
private void ParseLocation(int UpperLogicalLocation, int UnderLogicalLocation)
{
int LogicalLocation = UpperLogicalLocation & 0x0F; // Take bit 0-3
LogicalLocation += UnderLogicalLocation;
}
但这不能做出正确的结果。
int UpperLogicalLocation_Offset = 0x51;
int UnderLogicalLocation = 0x23;
int LogicalLocation = UpperLogicalLocation & 0x0F; // Take bit 0-3
LogicalLocation += UnderLogicalLocation;
Console.Write(LogicalLocation);
这应该给0x51(0101 )+ 0×23(00100011),
所以结果我要实现的是0001 + 00100011 = 000100100011(为0x123)
它几乎看起来像你认为'+'将执行字符串连接的等价物。是什么让你认为'0x51 + 0x23 = 000100100011'? – rliu
我知道这是你读过的最聪明的评论,但是你的函数'ParseLocation'不会返回任何东西。 – fiscblog