BFSchema.ByteArrayConverter.ConvertHexString C# (CSharp) Method

ConvertHexString() public static method

public static ConvertHexString ( string hex ) : byte[]
hex string
return byte[]
        public static byte[] ConvertHexString(string hex)
        {
            if (!hex.StartsWith("0x"))
                BfsCompiler.ReportError("Could not convert hex string to byte array!");

            hex = hex.Substring(2);

            int numberChars = hex.Length;
            byte[] bytes = new byte[numberChars / 2];
            for (int i = 0; i < numberChars; i += 2)
                bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
            return bytes;
        }