Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System.Runtime.InteropServices;
namespace ConsoleApp1
{
[StructLayout(LayoutKind.Explicit)]
struct SampleUnion
{
[FieldOffset(0)]
public uint x;
[FieldOffset(0)]
public byte byte1;
[FieldOffset(1)]
public byte byte2;
[FieldOffset(2)]
public byte byte3;
[FieldOffset(3)]
public byte byte4;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment