using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DM_Weight.Common { public class StaticClass { public static byte[] StrToHexByte(string hexString) { if (string.IsNullOrEmpty(hexString)) { return null; } hexString = hexString.Replace(" ", ""); if ((hexString.Length % 2) != 0) hexString += " "; byte[] returnBytes = new byte[hexString.Length / 2]; for (int i = 0; i < returnBytes.Length; i++) returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Replace(" ", ""), 16); return returnBytes; } } }