I have string like this “0100110011001” I want to convert it to byte array such that the array contains zeros and ones the problem that after the conversion the array contains 49, 48 I don’t why I tried many encoding for example I use the following code , and changed the encoding type
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
byte result = encoding.GetBytes(str);
any idea why that happen, and how to achieve the output I desire
48 is ASCII code for 0 and 49 is ASCII code for 1. There are many ways you can perform the conversion of this string, but this should be enough for you to manage on your own. Good luck 🙂
Possible solution: