Marshal.PtrToStructure Method (IntPtr, Type)
Marshals data from an unmanaged block of memory to a newly allocated managed object of the specified type.
Assembly: mscorlib (in mscorlib.dll)
[<SecurityCriticalAttribute>] [<ComVisibleAttribute(true)>] static member PtrToStructure : ptr:nativeint * structureType:Type -> Object
A pointer to an unmanaged block of memory.
The type of object to be created. This object must represent a formatted class or a structure.
Return ValueType: System.Object
A managed object containing the data pointed to by the ptr parameter.
The structureType parameter layout is not sequential or explicit.
The structureType parameter is a generic type.
structureType is null.
The class specified by structureType does not have an accessible default constructor.
The following example creates a managed structure, transfers it to unmanaged memory, and then transfers it back to managed memory using themethod.
The following example demonstrates how to marshal an unmanaged block of memory to a managed structure using themethod.
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1