字符串转成16进制数组

private static byte[] strToToHexByte(string hexString) //字符串转成16进制数组
{
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), 16);
return returnBytes;
}

posted @ 2013-10-24 20:41  shuenjian901  阅读(1388)  评论(0编辑  收藏  举报