using System.Linq; namespace Supercell.Laser.Titan.Util { public static class StringUtil { public static byte[] HexToBytes(string hex) { hex = hex.Replace(" ", "").Replace("-", ""); return Enumerable.Range(0, hex.Length) .Where(x => x % 2 == 0) .Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) .ToArray(); } } }