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)); }
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))); }