2017-04-15 61 views
0

我要遷移下面的代碼在C++到C#的reinterpret_cast在C#中,從C++遷移代碼以C#

https://www.unknowncheats.me/forum/counterstrike-global-offensive/186820-cs-matchid-4.html

我的問題了這裏, 我怎樣才能做到這一點在C#

uint64_t matchid = *reinterpret_cast<uint64_t*>(result.data()); 
uint64_t outcomeId = *reinterpret_cast<uint64_t*>(result.data() + 8); 
uint16_t tokenId = *reinterpret_cast<uint16_t*>(result.data() + 16); 

而結果必須是這個

matchId:3203527750019186923, outcomeId:32035318388280526 97, tokenId:13431

感謝

回答

0

在代碼有一個std::array<char, 18> result。在C#中它將是一個byte[] result

所以:

ulong matchId = BitConverter.ToUint64(result, 0); 
ulong outcomeId = BitConverter.ToUint64(result, 8); 
ulong tokenId = BitConverter.ToUint64(result, 16);