Beispiel #1
0
 public static int HexToInt(string str)
 {
     if (string.IsNullOrEmpty(str))
     {
         throw new ArgumentNullException();
     }
     if (!CRegex.IsHex(str))
     {
         throw new ArgumentException();
     }
     return(Convert.ToInt32(str, 16));
 }
Beispiel #2
0
        public static string HexToBinary(string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                throw new ArgumentNullException();
            }
            if (!CRegex.IsHex(str))
            {
                throw new ArgumentException();
            }
            int value = Convert.ToInt32(str, 16);

            return(Convert.ToString(value, 2).PadLeft(8, '0'));
        }