By default structs in C# are implemented with [StructLayout( LayoutKind.Sequential )]
for reasons basically stating that these type of objects are commonly used for COM Interop and their fields must stay in the order they were defined. Classes have LayoutKind.Auto
defined.
My question is should I explicitly state my structs as [StructLayout( LayoutKind.Auto )]
and would this give me any benefits over the default? I mean that if structs are initialized on stack, will it make any difference - i.e. the GC doesn't have to move them around? Also will it help when structs are initialized on the heap - i.e. are part of some class?