Specifies the offsets for fields in a class or struct for interoperability with unmanaged code.
[structoffset(offset)]
Field declarations.
structoffset is a single-use attribute. structoffset is an alias for System.InterOp.StructOffsetAttribute.
This attribute only applies to fields within a class or struct marked with the StructLayout(LayoutKind.Explicit) attribute.
No checking is performed on explicit offsets; you have total control over the layout of the fields.
The following PDH_RAW_COUNTER struct exactly matches the Platform SDK PDH_RAW_COUNTER data structure.
[structlayout(LayoutKind.Explicit)] public struct PDH_RAW_COUNTER { [structoffset(0)] public int CStatus; [structoffset(16)] public long FirstValue; [structoffset(4)] public FILETIME TimeStamp; [structoffset(24)] public long SecondValue; [structoffset(32)] public int MultiCount; } [structlayout(LayoutKind.Explicit)] public struct FILETIME { [structoffset(0)] public int dwLow; [structoffset(4)] public int dwHigh; }