.net中实现联合体类型

来源:互联网 发布:淘宝店后台操作 编辑:程序博客网 时间:2024/05/20 05:29
VC.Net语法:
/*表达式元素*/[System::Runtime::InteropServices::StructLayout( System::Runtime::InteropServices::LayoutKind::Explicit)]ref struct EI{public:[System::Runtime::InteropServices::FieldOffset(0)]System::Boolean boolValue;[System::Runtime::InteropServices::FieldOffset(0)]System::Int64 longValue;[System::Runtime::InteropServices::FieldOffset(0)]System::Decimal decimalValue;[System::Runtime::InteropServices::FieldOffset(0)]System::IntPtr ptrValue;};

C#语法:

        [System.Runtime.InteropServices.StructLayout( System.Runtime.InteropServices.LayoutKind.Explicit)]        struct UNION        {            [System.Runtime.InteropServices.FieldOffset(0)]            public byte b;            [System.Runtime.InteropServices.FieldOffset(0)]            public short s;            [System.Runtime.InteropServices.FieldOffset(0)]            public int i;            [System.Runtime.InteropServices.FieldOffset(0)]            public Guid guid;        }


 

原创粉丝点击