日期:2014-05-17  浏览次数:20833 次

十六进制的字符串:04 02 31 30 03,如何转换为byte[]?
如题:十六进制的字符串:04 02 31 30 03,如何转换为byte[]?

------解决方案--------------------
buye[] r = "04 02 31 30 03".Split(' ').Select(x => (byte)Convert.ToInt32(x, 16)).ToArray();
------解决方案--------------------
buye[] s = Regex.Matches("04 02 31 30 03","(?is)[a-f0-9]+").OfType<Match>().Select(t=>(byte)Convert.ToInt32(t.Value, 16)).ToArray();