0xfh???
你地确认“十六进制的数组”里面包括h么??好吧先把你那个h换成f,随便写个东西玩玩
string s = "daff134131";
List<byte> res = new List<byte>();
for (int i = 0; i < (s.Length + 1) / 2; i++)
{
string t = "0x" +new string(s.Skip(i * 2).Take(2).ToArray()).PadLeft(2, '0');
res.Add((byte)Convert.ToInt32(t, 16));
}
你地确认“十六进制的数组”里面包括h么??好吧先把你那个h换成f,随便写个东西玩玩
string s = "daff134131";
List<byte> res = new List<byte>();
for (int i = 0; i < (s.Length + 1) / 2; i++)
{
string t = "0x" +new string(s.Skip(i * 2).Take(2).ToArray()).PadLeft(2, '0');
res.Add((byte)Convert.ToInt32(t, 16));
}
for (int j = 0; j < (s.Length + 1) / 2; j++)
{
string t = "0x" + s.Substring(j*2,2);
res.Add(t);
}