C++代码是:
unsigned short* ui=(unsigned short*)&buf[110];
CountDev=ui[0];
buf 是 byte[]
,CountDev 是 unsigned int
(BCB6 编译器 x86)
我的尝试是: F#
...CountDev = System.BitConverter.ToInt32( [| arrayRead.[110]; arrayRead.[111] |] , 0 )
C#
...CountDev = System.BitConverter.ToInt32( [arrayRead[110]; arrayRead[111]] , 0 )
但说真的,我不能确定。请检查我的尝试,如果我做错了请告诉我。
最佳答案
您可以使用:
... = System.BitConverter.ToUint16(arrayRead, 110);
但它确实取决于大/小端(数组中字节的顺序)。
您将需要该规范或良好的测试用例。
关于c# - C++ 到 .NET : I need help with understanding C++ code to convert it to . NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7255457/