NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

structoffset

Specifies the offsets for fields in a class or struct for interoperability with unmanaged code.

[structoffset(offset)]

Applies To

Field declarations.

Parameters

offset
An int specifying the field offset, in bytes.

Remarks

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.

Example

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

See Also

C# Attributes