Possible duplicate:
How to convert byte array to hexadecimal string and vice versa in C #?
I have a text box that enters the string "AA 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF", I split it into String [], but now I need to get byte [] like this:
byte[] b6 = new byte[20] {0xAA,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88 ,0x99 ,0xAA ,0xBB,0xCC ,0xDD ,0xEE,0xFF};
can someone tell me how to do this. I tried using Convert.ToByte , but I get the error of not being able to convert String to byte. And I don't need to convert the values ββin hexadecimal, just to add 0x before each byte and add to the byte array.
source share