byte[] res = new byte[str.Length / 2];
for (int i = 0; i < str.Length /2; i++)
{
res[i] = Convert.ToByte(str.Substring(i * 2, 2), 16);
continue;
}
string strNum =System.Text.Encoding.ASCII.GetString(res);//System.Text.Encoding.ASCII.GetString
//strNum = strNum.Substring(0,a)
string a = "";
for (int i = 0; i < strNum.Length; i++)
{
if (i >= 1 && i <= 18)
{
a += strNum[i];
}
}
this.textBox1.Text = strNum.Substring(0, 18);
最后得到的结果“o?12345678912345”
正确结果:012345678912345678