Possible Duplicate:
How do you convert a string to ascii to binary in C#?
How to convert string such as "Hello"
to Binary sequence as 1011010
?
To convert a string to binary, we first append the string's individual ASCII values to a list ( l ) using the ord(_string) function. This function gives the ASCII value of the string (i.e., ord(H) = 72 , ord(e) = 101). Then, from the list of ASCII values we can convert them to binary using bin(_integer) .
WriteFile function (MSDN)
Try this:
string str = "Hello";
byte []arr = System.Text.Encoding.ASCII.GetBytes(str);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With