C++到.NET:我需要帮助理解C++代码才能将其转换为.NET

cnd*_*cnd 2 .net c# c++ f#

C++代码是:

unsigned short* ui=(unsigned short*)&buf[110];
            CountDev=ui[0];
Run Code Online (Sandbox Code Playgroud)

buf byte[]和CountDev是unsigned int

(BCB6编译器x86)

我的尝试是:F#

...CountDev  = System.BitConverter.ToInt32( [| arrayRead.[110]; arrayRead.[111] |] , 0 )
Run Code Online (Sandbox Code Playgroud)

C#

...CountDev  = System.BitConverter.ToInt32( [arrayRead[110]; arrayRead[111]] , 0 )
Run Code Online (Sandbox Code Playgroud)

但严重的是我无法确定.检查我的尝试,告诉我,如果我做错了请.

Hen*_*man 5

您可以使用:

  ... = System.BitConverter.ToUint16(arrayRead, 110);
Run Code Online (Sandbox Code Playgroud)

但它确实依赖于大/小端(数组中字节的顺序).
您将需要该规范或良好的测试用例.