How to use Union in C#
2011-03-10
There is no Union in C#, however, if you want to use convert Union from C++, do like the following:
C++:
struct Foo { float AA;**C#:**union { int BB; float CC; } as;
}
[StructLayout(LayoutKind.Explicit)] public struct SampleUnion { [FieldOffset(0)] public float AA; [FieldOffset(4)] public int BB; [FieldOffset(4)] public float CC; }