I have a struct that I would like to control the field layout on in the same manner of UNION structs in C++.
This is not for passing data to unmanaged code, it is to save memory space because field X will either be short integer or double, and other info in the struct can be used to determine if X should be interpreted as short integer or double.
I have found the docs for [StructLayout(LayoutKind.Explicit)] and for [FieldOffset(0)].
However, one doc state that these fields only control marshalling to unmanged code and does not impact managed storage, while another doc simply states that these attributes may be used to control field layouts.
Does anyone know how this is really implemented? I would like to use it to reduce my memory requirements with large arrays of this struct.
--------------------------------
From: Fuzzy
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>sVbH/6qB6kmbeSIYWHUaOw==</Id>