C++ code is :
unsigned short* ui=(unsigned short*)&buf[110];
CountDev=ui[0];
buf is byte[] and CountDev is unsigned int
(BCB6 Compiler x86)
My try is :
F#
...CountDev = System.BitConverter.ToInt32( [| arrayRead.[110]; arrayRead.[111] |] , 0 )
C#
...CountDev = System.BitConverter.ToInt32( [arrayRead[110]; arrayRead[111]] , 0 )
But seriously I can’t be sure about it. Check my try and tell me if I am doing it wrong please.
I would just do this to simply concatenate the two bytes and putting it into an int:
since you just need the least significant two byte, and int is 4 byte long (the most significant or sign bit is not touched), you can also use a signed int:
Edit:
Henk Holtermans solution is definitely the better choice as it uses the endianess of the current machine: