Convert Hex Value To Byte Array
using System; using System.Collections.Generic; using System.Text; using System.Globalization; public class BaseUtility { public static byte[] ConvertHexValueToByteArray(string value) { if (!value.StartsWith("0x")) throw new NonHexValueException(value); int size = (value.Length - 2) / 2; byte[] ret = new byte[size]; for (int i = 0; i < size; i++) ret[i] = (byte)int.Parse(value.Substring(i * 2 + 2, 2), NumberStyles.AllowHexSpecifier); ; return ret; } }