I am trying to read bytes.
Bytes: 0x83 0xF6
Those bytes are equal to 33782. I need a code to convert those bytes to 33782.
I have tried using this code:
Encoding.ASCII.GetString(new byte[] { 0x83, 0xF6 });
But it give this as a response: ??
Perhaps this?
(0x83 * 256 + 0xF6).ToString()
You are using the wrong Conversion, converting this byte array with ASCII String will not give the correct result. The reason you get ?? is because the values 0xF6, 0x83 lie outside the ASCII Table which is used to make the conversion in your case.
You should use BitConverter.ToUInt16()
var number = BitConverter.ToUInt16(new byte[] { 0xF6, 0x83}, 0).ToString();
You have to reverse the byte array first though for the Little/Big Endians.