Click or drag to resize
MarshalOffsetOf Method
Returns the field offset of the unmanaged form of the managed class.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static IntPtr OffsetOf(
	Type t,
	string fieldName
)

Parameters

t
Type: SystemType
A value type or formatted reference type that specifies the managed class. You must apply the StructLayoutAttribute to the class.
fieldName
Type: SystemString
The field within the t parameter.

Return Value

Type: IntPtr
The offset, in bytes, for the fieldName parameter within the specified class that is declared by platform invoke.
Exceptions
ExceptionCondition
ArgumentExceptionThe class cannot be exported as a structure or the field is nonpublic. Beginning with the .NET Framework version 2.0, the field may be private.
ArgumentNullExceptionThe t parameter is null.
See Also