How can I convert the string "0100" to a byte array {0,1,0,0} without using Convert.ToByte() on each element? The string may only contain characters 0 thru 9.
-
Following links should help 1) stackoverflow.com/questions/16072709/… 2) stackoverflow.com/questions/30545162/… 3) stackoverflow.com/questions/6254003/… 4) rextester.com/discussion/HHSUSW47299/…Atur– Atur2018-04-03 16:48:39 +00:00Commented Apr 3, 2018 at 16:48
-
Are you assuming that the characters in your string will always be digits in the range 0-9, or always in an 8-bit character set?Jim Mischel– Jim Mischel2018-04-03 16:48:44 +00:00Commented Apr 3, 2018 at 16:48
-
@atur I said not with Encoding, example A becomes 65. Just 0 becomes 0 in byte.JP_99– JP_992018-04-03 16:50:38 +00:00Commented Apr 3, 2018 at 16:50
-
@JimMischel Yes, sorry I will edit this.JP_99– JP_992018-04-03 16:51:13 +00:00Commented Apr 3, 2018 at 16:51
-
@JP_99 : Couple of links are without encoding. Moreover, see all answer not just the accepted onesAtur– Atur2018-04-03 16:51:46 +00:00Commented Apr 3, 2018 at 16:51
|
Show 3 more comments