How to convert a string of bits to byte array

Posted by Lily on Stack Overflow See other posts from Stack Overflow or by Lily
Published on 2010-06-07T13:03:48Z Indexed on 2010/06/07 13:22 UTC
Read the original article Hit count: 152

Filed under:
|
|
|

I have a string representing bits, such as:

"0000101000010000"

I want to convert it to get an array of bytes such as:

{0x0A, 0x10}

The number of bytes is variable but there will always be padding to form 8 bits per byte (so 1010 becomes 000010101).

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET