Export (0) Print
Expand All

Marshal.PtrToStructure(Of T) Method (IntPtr, T)

[Supported in the .NET Framework 4.5.1 and later versions]

Marshals data from an unmanaged block of memory to a managed object of the specified type.

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Sub PtrToStructure(Of T) ( _
	ptr As IntPtr, _
	structure As T _

Type Parameters


The type of structure. This must be a formatted class.


Type: System.IntPtr

A pointer to an unmanaged block of memory.

Type: T

The object to which the data is to be copied.


Structure layout is not sequential or explicit.

PtrToStructure(Of T)(IntPtr, T) is often necessary in COM interop and platform invoke when structure parameters are represented as IntPtr values. You cannot use this method overload with value types.

.NET Framework

Supported in: 4.6, 4.5.1

Supported in: Windows Phone 8.1

  • SecurityCriticalAttribute 

    requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Windows Phone 8.1

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft