Returns the field offset of the unmanaged form of the managed class.
Namespace: System.Runtime.InteropServicesAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax 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:
IntPtrThe offset, in bytes, for the
fieldName parameter within the specified class that is declared by platform invoke.
Exceptions Exception | Condition |
---|
ArgumentException | The 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. |
ArgumentNullException | The t parameter is null. |
See Also