I am not sure if this is correct but, if I am not mistaken, a unions is a [StructLayout(LayoutKind.Explicit)]
structure where 2 or more elements are on the same field offset.
So if I have this:
typedef union _FILE_SEGMENT_ELEMENT {
PVOID64 Buffer;
ULONGLONG Alignment;
}
would this be in C# as:
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit)]
public struct FileSegmentElement
{
[FieldOffset(0)]
public IntPtr Buffer;
[FieldOffset(0)]
public ulong Alignment;
}
or is this incorrect?