Beispiel #1
0
 public static int BinaryToInt(string str)
 {
     if (string.IsNullOrEmpty(str))
     {
         throw new ArgumentNullException();
     }
     if (!CRegex.IsBinary(str))
     {
         throw new ArgumentException();
     }
     return(Convert.ToInt32(str, 2));
 }
Beispiel #2
0
 public static string BinaryToHex(string str)
 {
     if (string.IsNullOrEmpty(str))
     {
         throw new ArgumentNullException();
     }
     if (!CRegex.IsBinary(str))
     {
         throw new ArgumentException();
     }
     return(string.Format("{0:X2}", Convert.ToInt32(str, 2)));
 }