I have FLV file I stored it to byte array and I can read it byte by byte.
I want to convert each byte to binary 0s and 1s
I want to convert variable b to binary 1s 0s. for example if b = 70 how to convert it to binary
what function I can use in C# to do this??
here is my code to read FLV file and store it byte array.
byte[] myArray = System.IO.File.ReadAllBytes(@"myFlvFile.flv");
int r = 0;
foreach (var b in myArray)
{
r += 1;
txtBit.Text = Environment.NewLine + Convert.ToString(b);
if (r == 50)
return;
}
If you want a bit-string:
so in your example, just add
, 2The second argument is the base you want to use.
and secondary, I have a little improvement on your code 🙂 this will do:
there is still stuff to improve on – you may want to look at
StringBuilderor similar 🙂 (it is quite inefficient to concatenate the text the way you do it.)