日期:2014-05-16  浏览次数:20865 次

C#是不是没有联合体(Union)的概念?
如题。。。。。。..
------解决方案--------------------
C#的联合提可以这样实现


        [StructLayout(LayoutKind.Explicit)]
        private struct UnionIntFloat                    // 其实就是Integer和Float都指向同一个内存
        {
            [FieldOffset(0)] public int Integer;
            [FieldOffset(0)] public float Float;
        }