点击或拖拽改变大小

SoftBasicByteToBoolArray 方法 (Byte, Int32)

从Byte数组中提取位数组,length代表位数,例如数组 03 A1 长度10转为 [1100 0000 10]
Extracts a bit array from a byte array, length represents the number of digits

命名空间:  HslCommunication.BasicFramework
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:12.0.0.0 (12.0.0.0)
语法
public static bool[] ByteToBoolArray(
	byte[] inBytes,
	int length
)

参数

inBytes
类型:SystemByte
原先的字节数组
length
类型:SystemInt32
想要转换的长度,如果超出自动会缩小到数组最大长度

返回值

类型:Boolean
转换后的bool数组
示例
ByteToBoolArray示例
byte[] buffer = new byte[2] { 0xB9, 0x28 };
bool[] result = SoftBasic.ByteToBoolArray( buffer, 15 );

// 结果如下
// result = new bool[] { true, false, false, true, true, true, false, true, false, false, false, true, false, true, false };

bool[] result2 = SoftBasic.ByteToBoolArray( buffer );
// 结果如下
// result2 = new bool[] { true, false, false, true, true, true, false, true, false, false, false, true, false, true, false, false };
参见