Skip to main content
.NET Framework Class Library
IntPtr Structure

A platform-specific type that is used to represent a pointer or a handle.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)
Syntax
<[%$TOPIC/5he14kz8_en-us_VS_110_1_0_0_0_0%]> _
<[%$TOPIC/5he14kz8_en-us_VS_110_1_0_0_0_1%](True)> _
Public Structure IntPtr _
	Implements [%$TOPIC/5he14kz8_en-us_VS_110_1_0_0_0_2%]
[[%$TOPIC/5he14kz8_en-us_VS_110_1_0_1_0_0%]]
[[%$TOPIC/5he14kz8_en-us_VS_110_1_0_1_0_1%](true)]
public struct IntPtr : [%$TOPIC/5he14kz8_en-us_VS_110_1_0_1_0_2%]
[[%$TOPIC/5he14kz8_en-us_VS_110_1_0_2_0_0%]]
[[%$TOPIC/5he14kz8_en-us_VS_110_1_0_2_0_1%](true)]
public value class IntPtr : [%$TOPIC/5he14kz8_en-us_VS_110_1_0_2_0_2%]
[<[%$TOPIC/5he14kz8_en-us_VS_110_1_0_3_0_0%]>]
[<[%$TOPIC/5he14kz8_en-us_VS_110_1_0_3_0_1%]>]
[<[%$TOPIC/5he14kz8_en-us_VS_110_1_0_3_0_2%](true)>]
type IntPtr =  
    struct 
        interface [%$TOPIC/5he14kz8_en-us_VS_110_1_0_3_0_3%] 
    end

The IntPtr type exposes the following members.

Constructors
  NameDescription
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IntPtr(Int32)Initializes a new instance of IntPtr using the specified 32-bit pointer or handle.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IntPtr(Int64)Initializes a new instance of IntPtr using the specified 64-bit pointer.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IntPtr(Void*)Initializes a new instance of IntPtr using the specified pointer to an unspecified type.
Top
Properties
  NameDescription
Public property Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps SizeGets the size of this instance.
Top
Methods
  NameDescription
Public method Static member Supported by Portable Class Library Supported in .NET for Windows Store apps AddAdds an offset to the value of a pointer.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps EqualsReturns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetHashCodeReturns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method Static member Supported by Portable Class Library Supported in .NET for Windows Store apps SubtractSubtracts an offset from the value of a pointer.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToInt32Converts the value of this instance to a 32-bit signed integer.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToInt64Converts the value of this instance to a 64-bit signed integer.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToPointerConverts the value of this instance to a pointer to an unspecified type.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToStringConverts the numeric value of the current IntPtr object to its equivalent string representation. (Overrides ValueTypeToString.)
Public method Supported by Portable Class Library Supported in .NET for Windows Store apps ToString(String)Converts the numeric value of the current IntPtr object to its equivalent string representation.
Top
Operators
  NameDescription
Public operator Static member Supported by Portable Class Library Supported in .NET for Windows Store apps AdditionAdds an offset to the value of a pointer.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps EqualityDetermines whether two specified instances of IntPtr are equal.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps (Int32 to IntPtr)Converts the value of a 32-bit signed integer to an IntPtr.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps (Int64 to IntPtr)Converts the value of a 64-bit signed integer to an IntPtr.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps (IntPtr to Void*)Converts the value of the specified IntPtr to a pointer to an unspecified type.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps (IntPtr to Int32)Converts the value of the specified IntPtr to a 32-bit signed integer.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps (IntPtr to Int64)Converts the value of the specified IntPtr to a 64-bit signed integer.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps (Void* to IntPtr)Converts the specified pointer to an unspecified type to an IntPtr.
Public operator Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps InequalityDetermines whether two specified instances of IntPtr are not equal.
Public operator Static member Supported by Portable Class Library Supported in .NET for Windows Store apps SubtractionSubtracts an offset from the value of a pointer.
Top
Fields
  NameDescription
Public field Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ZeroA read-only field that represents a pointer or handle that has been initialized to zero.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private method ISerializableGetObjectDataPopulates a SerializationInfo object with the data needed to serialize the current IntPtr object.
Top
Remarks

The IntPtr type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems.

The IntPtr type can be used by languages that support pointers, and as a common means of referring to data between languages that do and do not support pointers.

IntPtr objects can also be used to hold handles. For example, instances of IntPtr are used extensively in the System.IOFileStream class to hold file handles.

The IntPtr type is CLS-compliant, while the UIntPtr type is not. Only the IntPtr type is used in the common language runtime. The UIntPtr type is provided mostly to maintain architectural symmetry with the IntPtr type.

This type implements the ISerializable interface.

Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Thread Safety

This type is thread safe.