C#进制转换
计算校验码
/// <summary> /// 校验码 /// </summary> /// <param name="strReceInfo"></param> /// <returns></returns> private Boolean checkoutDataBuff(string strReceInfo) { int iCheckNum = 0; //校验码 for (int i =0 ; i < strReceInfo .Length - 2; i = i+2) { iCheckNum = iCheckNum + Convert.ToInt32(strReceInfo.Substring(i,2),16); } string strChkeckNum = Convert.ToString(iCheckNum, 16).PadLeft(2, '0'); strChkeckNum = strChkeckNum.Substring(strChkeckNum.Length - 2, 2).ToUpper(); if (strChkeckNum == strReceInfo.Substring(strReceInfo.Length - 2, 2)) return true; else return false; }