Export (0) Print
Expand All
3 out of 10 rated this helpful - Rate this topic

IntPtr Structure

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

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
[SerializableAttribute]
[ComVisibleAttribute(true)]
public struct IntPtr : ISerializable

The IntPtr type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryIntPtr(Int32)Initializes a new instance of IntPtr using the specified 32-bit pointer or handle.
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryIntPtr(Int64)Initializes a new instance of IntPtr using the specified 64-bit pointer.
Public methodSupported by the XNA FrameworkIntPtr(Void*)Initializes a new instance of IntPtr using the specified pointer to an unspecified type.
Top
  NameDescription
Public propertyStatic memberSupported by the XNA FrameworkSupported by Portable Class LibrarySizeGets the size of this instance.
Top
  NameDescription
Public methodStatic memberAddAdds an offset to the value of a pointer.
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryEqualsReturns a value indicating whether this instance is equal to a specified object. (Overrides ValueType.Equals(Object).)
Protected methodSupported by the XNA FrameworkSupported by Portable Class LibraryFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryGetHashCodeReturns the hash code for this instance. (Overrides ValueType.GetHashCode().)
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkSupported by Portable Class LibraryMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberSubtractSubtracts an offset from the value of a pointer.
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryToInt32Converts the value of this instance to a 32-bit signed integer.
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryToInt64Converts the value of this instance to a 64-bit signed integer.
Public methodSupported by the XNA FrameworkToPointerConverts the value of this instance to a pointer to an unspecified type.
Public methodSupported by the XNA FrameworkSupported by Portable Class LibraryToString()Converts the numeric value of the current IntPtr object to its equivalent string representation. (Overrides ValueType.ToString().)
Public methodToString(String)Converts the numeric value of the current IntPtr object to its equivalent string representation.
Top
  NameDescription
Public operatorStatic memberAdditionAdds an offset to the value of a pointer.
Public operatorStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryEqualityDetermines whether two specified instances of IntPtr are equal.
Public operatorStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryExplicit(Int32 to IntPtr)Converts the value of a 32-bit signed integer to an IntPtr.
Public operatorStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryExplicit(Int64 to IntPtr)Converts the value of a 64-bit signed integer to an IntPtr.
Public operatorStatic memberSupported by the XNA FrameworkExplicit(IntPtr to Void*)Converts the value of the specified IntPtr to a pointer to an unspecified type.
Public operatorStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryExplicit(IntPtr to Int64)Converts the value of the specified IntPtr to a 64-bit signed integer.
Public operatorStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryExplicit(IntPtr to Int32)Converts the value of the specified IntPtr to a 32-bit signed integer.
Public operatorStatic memberSupported by the XNA FrameworkExplicit(Void* to IntPtr)Converts the specified pointer to an unspecified type to an IntPtr.
Public operatorStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryInequalityDetermines whether two specified instances of IntPtr are not equal.
Public operatorStatic memberSubtractionSubtracts an offset from the value of a pointer.
Top
  NameDescription
Public fieldStatic memberSupported by the XNA FrameworkSupported by Portable Class LibraryZeroA read-only field that represents a pointer or handle that has been initialized to zero.
Top
  NameDescription
Explicit interface implemetationPrivate methodISerializable.GetObjectDataPopulates a SerializationInfo object with the data needed to serialize the current IntPtr object.
Top

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.IO.FileStream 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.

.NET Framework

Supported in: 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

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

This type is thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.