ToIntPtr Method

GCHandle.ToIntPtr Method

Note: This method is new in the .NET Framework version 2.0.

Returns the internal integer representation of a GCHandle object.

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

static IntPtr ToIntPtr (
	GCHandle value
public static IntPtr ToIntPtr (
	GCHandle value
public static function ToIntPtr (
	value : GCHandle
) : IntPtr



A GCHandle object to retrieve an internal integer representation from.

Return Value

An IntPtr object that represents a GCHandle object.

The following code example shows an App class that creates a handle to a managed object using the GCHandle.Alloc method, which prevents the managed object from being collected. A call to the EnumWindows method passes a delegate and a managed object (both declared as managed types, but not shown), and casts the handle to an IntPtr object. The unmanaged function passes the type back to the caller as a parameter of the callback function.

No code example is currently available or this language may not be supported.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, 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.

.NET Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft