Mega Code Archive

 
Categories / C# / Data Types
 

Hex To Bytes

using System; using System.Globalization; using System.Text; public static class MobileUtil {     public static byte[] HexToBytes(string hex)     {         hex = hex.Trim();         byte[] bytes = new byte[hex.Length / 2];         for (int index = 0; index < bytes.Length; index++)         {             bytes[index] = byte.Parse(hex.Substring(index * 2, 2), NumberStyles.HexNumber);         }         return bytes;     } }