有C++代码如下
BOOL CheckReceive( BYTE* p_pbyPacket, DWORD p_dwPacketLen, WORD p_wPrefix, WORD p_wCMDCode ) { int i; WORD w_wCalcCheckSum, w_wCheckSum; ST_RCM_PACKET* w_pstRcmPacket; w_pstRcmPacket = (ST_RCM_PACKET*)p_pbyPacket; //. Check prefix code if (p_wPrefix != w_pstRcmPacket->m_wPrefix) return FALSE; //. Check checksum w_wCheckSum = MAKEWORD(p_pbyPacket[p_dwPacketLen-2], p_pbyPacket[p_dwPacketLen-1]); w_wCalcCheckSum = 0; for (i=0; i<p_dwPacketLen-2; i++) { w_wCalcCheckSum = w_wCalcCheckSum + p_pbyPacket[i]; } if (w_wCheckSum != w_wCalcCheckSum) return FALSE; if (p_wCMDCode != w_pstRcmPacket->m_wCMDCode) { return FALSE; } return TRUE; }
这个MAKEWORD用C#该怎么写,求指导
解决方案
40
用BitConverter