Good afternoon, I can not understand why when using Marshal.SizeOf() for a type where there is a variable array, the function returns other values. For example, I have a structure on my hands:
 struct MyStruct { public int[] Value; } When using Marshal.SizeOf(typeof(MyStruct)) 4, as I understand it, the size of the array type is taken, that is, int (4 bytes, that's right). But if I write something like this:
 MyStruct myStruct = new MyStruct() { Value = new int[] { 1, 2 } }; Marshal.SizeOf(myStruct); Obviously, the result should be 8, but it gives 4. Is there a way to declare an array of a certain length in the structure so that Marshal.SizeOf correct results?