
本文共 2191 字,大约阅读时间需要 7 分钟。
������������������������������������������������Socket���������������������������hex������������������������������������DEMO���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������
// 16������������������������������private static byte[] HexStrToByteArray(string hexString){ hexString = hexString.Replace(" ", ""); if ((hexString.Length % 2) != 0) hexString += " "; byte[] returnBytes = new byte[hexString.Length / 2]; for (int i = 0; i < returnBytes.Length; i++) returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Trim(), 16); return returnBytes;}
// ���������������16���������������public static string ByteToHexString(byte[] bytes){ string returnStr = ""; if (bytes != null) { for (int i = 0; i < bytes.Length; i++) returnStr += bytes[i].ToString("X2"); } return returnStr;}
���������ToString("X2")
���C#���������������������������������������������������
- X���������������������Hex������������
- 2������������������������������������������������������������������0������������������
- ���������������������������������������0xA���������������������"XA"������������������������0xA������������"A" - ���������������������������������������������������������������������������������������������������
���������
0xA
������������"A"���������������������������������������������"A"������0x1A
������������"1A"���- ������������������������"0x"���������������������������������������"X2"������"X"���
���������������������������������������������������������������������������������������������������
���������������������������������������������BitConverter.ToString
���������
// ���������������string strHex = BitConverter.ToString(receivedBytes);strHex = strHex.Replace("-", " ");
������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
