1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| using System;
|
| namespace HMI.Core.Util
| {
| public class HexUtil
| {
| public static byte[] ToBytesFromHexString(string hexString)
| {
| //以 ' ' 分割字符串,并去掉空字符
| string[] chars = hexString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
| byte[] returnBytes;
| returnBytes = BitConverter.GetBytes(Convert.ToInt32(chars[0]));
| return returnBytes;
| }
| }
| }
|
|