converting bits sequence into binary or string
I have stored six different bits into my SQL Server database and now I want to combine that all into ASCII or otherwise in string to send on serial port. so, how could I?
my 6 different bits stored into database in six different field name as v1,...., v6. and its in format of bit.
Re: converting bits sequence into binary or string
You could try the System.Collections.BitArray class and its Cast<> method.
Re: converting bits sequence into binary or string
i on the sql portion no comment, as for the bits to ascii
you would could use bit math
turn the bits into a byte ...n , then
cast that byte to char c = (char)n;
though its been a minute this may not be exact
something akin to or-ing each flag to a position in a byte
byte n = 0;
n = n | bitflag05 << 5 ;
char c = (char)n;
to read it cast the char back to a byte then by and-ing &
if( n & ( (byte)1 << 5 ) > 0 ) { }
...
you would google for a tutorial on bit shifting and bit math operators for this part