15,798,200 members
See more:
Hi, I have a byte value array containing elements, I want to get the value by block and convert to decimal, element block value in predefined. Assume, I have this code as below.

```var _bytes= new byte[]{0, 12, 0, 6, 19, 136};
var _size = 3; //byte with 3 item is decimal
var _num = 2 ; //length of block define in array byte
var _result = "";
for (int i = 0; i < _size; i++)
{
//get value decimal in byte array follow the block define
//var _id = BitConverter.ToInt16(_bytes[i] * 2, 2);
_result += _id + " ";
}
//the _result should be "12 6 5000"
//0 12 is decimal 12
//0 6 is decimal 6
//19 136 is decimal 5000```

What I have tried:

try to convert but result not correct
Posted
Updated 11-Jul-23 0:36am
v2
Richard MacCutchan 11-Jul-23 6:04am
How do you get 5000 from 19 and 136?
Convert 19, 136 to Hexa first , after that convert to Decimal , It's 5000

## Solution 1

Probably this is working

`var _id = Convert.ToDecimal(Convert.ToInt32(BitConverter.ToInt16((_bytes[i] * 2, 2).Reverse().ToArray(), 0).ToString("X4"), 16));`