[Serializable] |
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 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.
ctor #1 | Overloaded:.ctor(int value) Initializes a new instance of IntPtr using the specified 32-bit pointer or handle. |
ctor #2 | Overloaded:.ctor(long value) Initializes a new instance of IntPtr using the specified 64-bit pointer. |
ctor #3 | Overloaded:.ctor(void* value) Initializes a new instance of IntPtr using the specified pointer to an unspecified type. |
Zero | A read-only field that represents a pointer or handle that has been initialized to zero. |
Size | Read-only Gets the size of this instance. |
Equals | Overridden: Returns a value indicating whether this instance is equal to a specified object. |
GetHashCode | Overridden: Returns the hash code for this instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToInt32 | Converts the value of this instance to a 32-bit signed integer. |
ToInt64 | Converts the value of this instance to a 64-bit signed integer. |
ToPointer | Converts the value of this instance to a pointer to an unspecified type. |
ToString | Overloaded:ToString() Overridden: Converts the numeric value of this instance to its equivalent string representation. |
ToString | Overloaded:ToString(string format) |
op_Equality | Determines whether two specified instances of IntPtr are equal. |
op_Explicit (convert System.Int32 to System.IntPtr) |
Overloaded:op_Explicit(int value) Converts the value of a 32-bit signed integer to an IntPtr. |
op_Explicit (convert System.Int64 to System.IntPtr) |
Overloaded:op_Explicit(long value) Converts the value of a 64-bit signed integer to an IntPtr. |
op_Explicit (convert System.IntPtr to System.Int32) |
Overloaded:op_Explicit(IntPtr value) Converts the value of the specified IntPtr to a 32-bit signed integer. |
op_Explicit (convert System.IntPtr to System.Int64) |
Overloaded:op_Explicit(IntPtr value) Converts the value of the specified IntPtr to a 64-bit signed integer. |
op_Explicit (convert System.IntPtr to System.Void*) |
Overloaded:op_Explicit(IntPtr value) Converts the value of the specified IntPtr to a pointer to an unspecified type. |
op_Explicit (convert System.Void* to System.IntPtr) |
Overloaded:op_Explicit(void* value) Converts the specified pointer to an unspecified type to an IntPtr. |
op_Inequality | Determines whether two specified instances of IntPtr are not equal. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public IntPtr( |
value
public IntPtr( |
value
Exception Type | Condition |
---|---|
OverflowException | On a 32-bit platform, value is too large to represent as an IntPtr. |
[CLSCompliant(false)] |
value
public static readonly IntPtr Zero;
|
For example, assume the variable, ip, is an instance of IntPtr. You can determine if it has been set by comparing it to the value returned by a constructor, for example: "
if ip != new
IntPtr(0)...
". However, invoking a constructor to get an unintialized pointer is inefficient. It is better to code either "
if ip != IntPtr.Zero...
", or "
if
!IntPtr.Zero.Equals(ip)...
".
public static int Size {get;}
|
obj
~IntPtr(); |
public override int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
value1
value2
value
value
Exception Type | Condition |
---|---|
OverflowException | On a 32-bit platform, value is too large to represent as an IntPtr. |
value
Exception Type | Condition |
---|---|
OverflowException | On a 64-bit platform, the value of value is too large to represent as a 32-bit signed integer. |
value
value
value
value1
value2
public int ToInt32(); |
Exception Type | Condition |
---|---|
OverflowException | On a 64-bit platform, the value of this instance is too large to represent as a 32-bit signed integer. |
public long ToInt64(); |
[CLSCompliant(false)] |
public override string ToString(); |
public string ToString( |
format