One fine day in the middle of the night Arjen wrote in
news:de**********@news6.zwoll1.ov.home.nl:
Hi,
I can read in a file with the binaryreader. But how can I get all the
bits ("1" and "0") inside my textbox?
(I now get the number 68)
You're going to have to parse the number.
First you need to know the size of your value ( 68 appears to be a byte,
so the size would be 8... 8 bits for a byte )
Then you need a mask that you'll walk over your number. Start your mask
at a value of 0x80 and walk down from there. Then create a string to hold
your final binary number. Then walk the mask down the value:
string ConvertHexToBinary( byte myByte /* = 0x44 */ )
{
byte mask = 0x80;
string myBinaryOutput = "";
for( int i = 0; i < 8; i++ )
{
String bit = "";
if( ( myByte & mask ) != 0 )
bit = "1";
else
bit = "0";
myBinaryOutput += bit;
mask >>= 1;
}
return myBinaryOutput;
}
Hope that helps you.
--
Bryan