using System.Collections;
using System.Collections.Generic;
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Reflection;
using System.Runtime.InteropServices;
public class ByteConvertHelper
{
/// <summary>
/// 将结构体对象转换为byte数组
/// </summary>
/// <param name="obj">被转换对象</param>
/// <returns>转换后byte数组</returns>
public static byte[] Object2Bytes(object obj)
{
int size = Marshal.SizeOf(obj);
byte[] bytes = new byte[1024];
IntPtr structPtr = Marshal.AllocHGlobal(size);
Marshal
using System.Collections.Generic;
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Reflection;
using System.Runtime.InteropServices;
public class ByteConvertHelper
{
/// <summary>
/// 将结构体对象转换为byte数组
/// </summary>
/// <param name="obj">被转换对象</param>
/// <returns>转换后byte数组</returns>
public static byte[] Object2Bytes(object obj)
{
int size = Marshal.SizeOf(obj);
byte[] bytes = new byte[1024];
IntPtr structPtr = Marshal.AllocHGlobal(size);
Marshal