Skip to content

Instantly share code, notes, and snippets.

@kusa-mochi
Created July 18, 2020 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kusa-mochi/90a7c0ef8a5d580043af77cad6e63492 to your computer and use it in GitHub Desktop.
Save kusa-mochi/90a7c0ef8a5d580043af77cad6e63492 to your computer and use it in GitHub Desktop.
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