I have a problem in converting String
(contains hexadecimal value) to byte
. Like below code.
String hexaString = "0xA1";
byte hexaByte = (byte)hexaString;
Not able to convert from String to byte like this code (Getting the Error : Cannot cast from String to byte
).
But i am able to do like this
byte hexaByte = (byte)0xA1; //this is giving output as -95
Anyone please guide me how can i do like the first method(this also output the value -95). Because, the last two digit i will get from db and i need to convert it to hexadecimal(appending 0x). Then i should send to client as a byte value.
Thanks in Advance !