bool[] boolArray = { true, false, true, true, false, true, true, false };
byte result = 0;
for (int i = 0; i < boolArray.Length; i++)
{
// 将布尔值转换为对应的位
byte bit = boolArray[i] ? (byte)1 : (byte)0;
// 使用左移位运算将位合并到结果字节中
result = (byte)((result << 1) | bit);
}
Console.WriteLine(result); // 输出: 182,对应的二进制为 10110110