从字符串位转换为字节或hex

我有一个包含以下7位的字符串:1101000。如何将其转换为byte或int?

这应该这样做:

string binaryText = "1101000"; int value1 = Convert.ToInt32(binaryText, 2) // 104 byte value2 = Convert.ToByte(binaryText, 2); // 104 

转换为字节数组:

 System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); byte [] dBytes = encoding.GetBytes(str);