From hex string s of 2n digits, build the equivalent array a of n bytes. Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).
byte[] a = new byte[s.Length/2];
for (int i = 0, h = 0; h < s.Length; i++, h += 2)
{
a[i] = (byte) Int32.Parse(s.Substring(h, 2), System.Globalization.NumberStyles.HexNumber);
}
byte[] a = new byte[s.Length/2];
for (int i = 0, h = 0; h < s.Length; i++, h += 2)
{
a[i] = (byte) Int32.Parse(s.Substring(h, 2), System.Globalization.NumberStyles.HexNumber);
}