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

字符串转换byte[].

            string s = "3E-2E-3D-43-16-0E";
            var d = s.Split('-');
            byte[] by = new byte[d.Length];
            for (int i = 0; i < d.Length; i++)
            {
                by[i] = ??;
            }


??这个地方怎么写 我才能得到下面的结果

            byte[] result = new byte[6];
            result[0] = 0x3e;
            result[1] = 0x2e;
            result[2] = 0x3d;
            result[3] = 0x43;
            result[4] = 0x16;
            result[5] = 0x0e;

------解决方案--------------------
string s = "3E-2E-3D-43-16-0E";
byte[] by = s.Split('-').Select(x => Convert.ToByte(x, 16)).ToArray();
------解决方案--------------------
我觉得楼主如果能看明白我的那段代码,还得需要一些时间。。。
------解决方案--------------------
该回复于2013-08-06 11:17:08被版主删除