How do I convert byte array to UInt32 array?
问题 Lets say In C++ I got code like this.. void * target uint32 * decPacket = (uint32 *)target; So in C# it would be like.. byte[] target; UInt32[] decPacket = (UInt32[])target; Cannot convert type byte[] to uint[] How do I convert this memory aligning thing C++ does to arrays to C#? 回答1: Well, something close would be to use Buffer.BlockCopy: uint[] decoded = new uint[target.Length / 4]; Buffer.BlockCopy(target, 0, decoded, 0, target.Length); Note that the final argument to BlockCopy is always