C#实现联合体

        [StructLayout(LayoutKind.Explicit, Size = 8)]
        public struct TypeTransform
        {
            [FieldOffset(0)]
            public float f;

            [FieldOffset(0)]
            public int i;

            [FieldOffset(0)]
            public double d;

            [FieldOffset(0)]
            public long l;

            //[FieldOffset(0)]
            //public byte b1;

            //[FieldOffset(1)]
            //public byte b2;

            //[FieldOffset(2)]
            //public byte b3;

            //[FieldOffset(3)]
            //public byte b4;
        }

 

posted @ 2018-11-11 18:53  时空观察者9号  阅读(2664)  评论(0编辑  收藏  举报