数组转结构体问题
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]public struct gooseData
{
/// <summary>
/// 目标MAC
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public byte[] DMAC;
/// <summary>
/// 源MAC
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public byte[] SMAC;
/// <summary>
/// TPID=0x8100
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public byte[] TPID;
/// <summary>
/// TCI=0x8000
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public byte[] TCI;
/// <summary>
/// APPID=0x88b8
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public byte[] APPID;
/// <summary>
/// data=110(bytes)
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 110)]
public byte[] Data;
}
我以太网收到一帧数组(128个字节)数据,然后想把数据放入以上结构体中,然后从结构体内取值、显示。请各位帮帮忙!!