开发者

How to convert a boolean array to byte and back in VB 2010

开发者 https://www.devze.com 2023-03-09 03:43 出处:网络
I am trying to write and read bytes from usb device. I have an array dout(8) of boolean say f,t,t,f,t,t,f,t representing switch states.

I am trying to write and read bytes from usb device. I have an array dout(8) of boolean say f,t,t,f,t,t,f,t representing switch states. I need to convert that to a variable DataOu开发者_运维知识库t as byte. 01101101

Later I read the usb device. This gives me a variable Data as byte 10110100 I need to convert that to an array DIn(10) of boolean t,f,t,t,f,t,f,f

All my code attempts have failed.


Try the System.BitConverter class.


If you don't want to worry about thinking in binary, there is a class called BitArray that will help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消