How do you convert 3 bytes into a 24 bit number in C#? -


I have an array of bytes, which I read from the header section of the message. These bytes contain the length of the message. Never exceed 3 bytes and they are ordered from LSB to MSB. So in the example below, there are 39 LSBs and 2 MSBs.

  var data = new byte [] {39, 213, 2};  

In the above example, how can I take those bytes and convert to a number (int, short, etc.)?

  var num = data [0] + (data [1]  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -