110,533
社区成员
发帖
与我相关
我的任务
分享
string hexstring = "A1B23D8F";
MatchCollection mc = Regex.Matches(hexstring, "[A-F0-9]{2}");
byte[] bytes = new byte[mc.Count];
for (int i = 0; i < mc.Count; i++)
{
bytes[i] = byte.Parse(mc[i].Value, System.Globalization.NumberStyles.HexNumber);
}
//bytes就是你要的
string hexstring = "A1B23D8F";
byte[] bytes = System.Text.RegularExpressions.Regex.Matches(hexstring, "[A-F0-9]{2}").Cast<Match>().Select(m => byte.Parse(m.Value, System.Globalization.NumberStyles.HexNumber)).ToArray();