Goedel.Debug.Trace.HexToByte C# (CSharp) Method

HexToByte() public static method

Convert string of hex data to byte array. [why isn't this in the conversions library?)
public static HexToByte ( string input ) : byte[]
input string String to convert.
return byte[]
        public static byte[] HexToByte(string input) {
            int Valid = 0;
            bool High = true;
            int Buffer = 0;
            int Index = 0;

            foreach (char c in input) {
                if (HexValue(c) >= 0) Valid++;
                }

            var Result = new byte[(Valid + 1) / 2];
            foreach (char c in input) {
                var h = HexValue(c);
                if (h >= 0) {
                    if (High) {
                        Buffer = h;
                        }
                    else {
                        Result[Index++] = (byte)(h + (Buffer * 16));
                        }

                    High = !High;
                    }
                }
            return Result;
            }