I need to create an array of bytes with the following content:
byte[] arr = new byte { 0x4f, 0x4e };
I happen to have the string "ON", where "O" = 4f in hex and "N" = 4e
I have tried to store the hex value directly in the byte array without 0x
, but when I send it to the serial port in this way, it does not work, it has to be in 0x00
format.
How to convert the string to an array in hexadecimal?