FieldOffsetAttribute Class
Assembly: mscorlib (in mscorlib.dll)
'Declaration <ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.Field, Inherited:=False)> _ Public NotInheritable Class FieldOffsetAttribute Inherits Attribute 'Usage Dim instance As FieldOffsetAttribute
/** @attribute ComVisibleAttribute(true) */ /** @attribute AttributeUsageAttribute(AttributeTargets.Field, Inherited=false) */ public final class FieldOffsetAttribute extends Attribute
ComVisibleAttribute(true) AttributeUsageAttribute(AttributeTargets.Field, Inherited=false) public final class FieldOffsetAttribute extends Attribute
You can apply this attribute to fields.
This attribute is used when System.Runtime.InteropServices.StructLayoutAttribute, with LayoutKind.Explicit passed to its constructor, is applied to a class or structure to specify the offset of each non- static or constant member within the unmanaged representation of that class or structure.
The following example demonstrates how to apply the FieldOffsetAttribute to members of a class with an explicit layout.
<StructLayout(LayoutKind.Explicit)> _ Public Class SYSTEM_INFO <FieldOffset(0)> Private OemId As System.UInt64 <FieldOffset(4)> Private PageSize As System.UInt64 <FieldOffset(16)> Private ActiveProcessorMask As System.UInt64 <FieldOffset(20)> Private NumberOfProcessors As System.UInt64 <FieldOffset(24)> Private ProcessorType As System.UInt64 End Class
/** @attribute StructLayout(LayoutKind.Explicit)
*/
public class SYSTEM_INFO
{
/** @attribute FieldOffset(0)
*/
public long oemId;
/** @attribute FieldOffset(4)
*/
public long pageSize;
/** @attribute FieldOffset(16)
*/
public long activeProcessorMask;
/** @attribute FieldOffset(20)
*/
public long numberOfProcessors;
/** @attribute FieldOffset(24)
*/
public long processorType;
} //SYSTEM_INFO
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.