public static bool InHexFormat(string hexString)
        {
            bool flag = true;

            foreach (char c in hexString)
            {
                if (!HexEncoding.IsHexDigit(c))
                {
                    flag = false;
                    break;
                }
            }
            return(flag);
        }
        public static int GetByteCount(string hexString)
        {
            int num = 0;

            for (int index = 0; index < hexString.Length; ++index)
            {
                if (HexEncoding.IsHexDigit(hexString[index]))
                {
                    ++num;
                }
            }
            if (num % 2 != 0)
            {
                --num;
            }
            return(num / 2);
        }
        public static byte[] GetBytes(string hexString, out int discarded)
        {
            discarded = 0;
            string str = "";

            for (int index = 0; index < hexString.Length; ++index)
            {
                char c = hexString[index];
                if (HexEncoding.IsHexDigit(c))
                {
                    str += (string)(object)c;
                }
                else
                {
                    ++discarded;
                }
            }
            if (str.Length % 2 != 0)
            {
                ++discarded;
                str = str.Substring(0, str.Length - 1);
            }
            byte[] numArray = new byte[str.Length / 2];
            int    index1   = 0;

            for (int index2 = 0; index2 < numArray.Length; ++index2)
            {
                string hex = new string(new char[2]
                {
                    str[index1],
                    str[index1 + 1]
                });
                numArray[index2] = HexEncoding.HexToByte(hex);
                index1          += 2;
            }
            return(numArray);
        }