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; } } }