System.FormatException无法找到可识别的数字

时间:2014-10-07 05:33:25

标签: c# windows-phone-8

当我尝试使用以下代码将十六进制字符串转换为字节数组时,我收到此错误。请帮忙。

protected static byte[] HexStringToByte(string hexString)
    {
        try
        {
            int bytesCount = (hexString.Length) / 2;
            byte[] bytes = new byte[bytesCount];
            for (int x = 0; x < bytesCount; ++x)
            {
                bytes[x] = Convert.ToByte(hexString.Substring(x * 2, 2), 16);
            }
            return bytes;
        }
        catch
        {
            throw;
        }
    }

1 个答案:

答案 0 :(得分:0)

HexaDecimal值

  

0ADB4DA38093W3350E49B0BA90O04A6C

您在评论中分享的

无效。

所以问题出在你获得这个HexaDecimal值的代码中。