.net中实现联合体类型

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;
        }


 

你可能感兴趣的:(.net中实现联合体类型)