据说是可以将字节数组转换成结构。我还没有测试。等要用的时候再来看看吧。先记到这儿。
字节数组转换成结构using System.Runtime.InteropServices;
字节数组转换成结构
字节数组转换成结构
static object BytesToStruct(byte[] bytes, Type strcutType)
{
字节数组转换成结构
int size = Marshal.SizeOf(strcutType);
字节数组转换成结构IntPtr buffer 
= Marshal.AllocHGlobal(size);
字节数组转换成结构
try
{
字节数组转换成结构Marshal.Copy(bytes, 
0, buffer, size);
字节数组转换成结构
return Marshal.PtrToStructure(buffer, strcutType);
字节数组转换成结构}

字节数组转换成结构
finally
{
字节数组转换成结构Marshal.FreeHGlobal(buffer);
字节数组转换成结构}

字节数组转换成结构}

字节数组转换成结构
字节数组转换成结构

相关文章:

  • 2021-06-25
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2021-08-12
相关资源
相似解决方案