public struct IntPtr
Object
ValueType
IntPtr
mscorlib
RuntimeInfrastructure
An implementation-specific type that is used to represent a pointer or a handle.
The IntPtr type is designed to be an implementation-sized pointer. An instance of this type is expected to be the size of anative int
for the current implementation.For more information on the
native int
type, see Partition II of the CLI Specification.[Note: The IntPtr type provides CLS-compliant pointer functionality.
IntPtr instances can also be used to hold handles.
The IntPtr type is CLS-compliant while the UIntPtr type is not. The UIntPtr type is provided mostly to maintain architectural symmetry with the IntPtr type.
]
System Namespace
IntPtr Constructors
IntPtr(int) Constructor
IntPtr(long) Constructor
IntPtr Methods
IntPtr.Equals Method
IntPtr.GetHashCode Method
IntPtr.ToInt32 Method
IntPtr.ToInt64 Method
IntPtr.ToPointer Method
IntPtr.ToString Method
IntPtr.op_Equality Method
IntPtr.op_Inequality Method
IntPtr Fields
IntPtr Properties
public IntPtr(int value);
Constructs a new IntPtr structure using the specified Int32 containing a pointer or a handle.
- value
- A Int32 containing a pointer or a handle.
System.IntPtr Structure, System Namespace
public IntPtr(long value);
Constructs a new IntPtr structure using the specified Int64 containing a pointer or a handle.
- value
- A Int64 containing a pointer or a handle.
Exception Type Condition OverflowException The current platform is a 32-bit platform and the value of the current instance is greater than System.Int32.MaxValue or less than System.Int32.MinValue.
System.IntPtr Structure, System Namespace
public override bool Equals(object obj);
Determines whether the current instance and the specified Object represent the same type and value.
- obj
- The Object to compare to the current instance.
true
if obj is a IntPtr instance and has the same value as the current instance. If obj is a null reference or is not an instance of IntPtr, returnsfalse
.
[Note: The method overrides System.Object.Equals(System.Object).]
System.IntPtr Structure, System Namespace
public override int GetHashCode();
Generates a hash code for the current instance.
A Int32 containing the hash code for the current instance.
[Note: The algorithm used to generate the hash code is unspecified.]
[Note: This method overrides System.Object.GetHashCode.]
System.IntPtr Structure, System Namespace
public int ToInt32();
Converts the value of the current instance to a Int32.
A Int32 containing the same value as the current instance.
Exception Type Condition OverflowException The current platform is not a 32-bit platform and the value of the current instance is greater than System.Int32.MaxValue or less than System.Int32.MinValue.
System.IntPtr Structure, System Namespace
public long ToInt64();
Converts the value of the current instance to a Int64.
A Int64 containing the same value as the current instance.
System.IntPtr Structure, System Namespace
unsafe public void* ToPointer();
Converts the value of the current instance to a pointer tovoid
.
A pointer tovoid
.
This member is not CLS-compliant. For a CLS-compliant alternative, use System.IntPtr.ToInt32.[Note: A pointer to
void
points to memory containing data of an unspecified type.]
CLSCompliantAttribute(false)
System.IntPtr Structure, System Namespace
public override string ToString();
Returns a String representation of the value of the current instance.
A String representation of the current instance.
[Note: If System.IntPtr.Size for the current instance is 4, System.IntPtr.ToString is equivalent to System.Int32.ToString(); otherwise, this method is equivalent to System.Int64.ToString().This method overrides System.Object.ToString.
]
System.IntPtr Structure, System Namespace
public static bool operator ==(IntPtr value1, IntPtr value2);
Determines whether the two specified instances of IntPtr represent the same value.
- value1
- The first IntPtr to compare for equality.
- value2
- The second IntPtr to compare for equality.
true
if value1 represents the same value as value2; otherwise,false
.
System.IntPtr Structure, System Namespace
public static bool operator !=(IntPtr value1, IntPtr value2);
Determines whether the two specified instances of IntPtr represent different values.
- value1
- The first IntPtr to compare for inequality.
- value2
- The second IntPtr to compare for inequality.
true
if value1 represents a different value than value2; otherwise,false
.
System.IntPtr Structure, System Namespace
public static readonly IntPtr Zero;
Represents a pointer or handle that has been initialized as zero.
[Note: The value of this field is notnull
, but is instead a pointer which has been assigned the value zero. Use this field to efficiently determine whether an instance of IntPtr has been set to a value other than zero. For example, if ip is a IntPtr instance, using ip != IntPtr.Zero is more efficient than ip != new IntPtr(0) to test if ip has been set to a value other than zero.]
System.IntPtr Structure, System Namespace
public static int Size { get; }
Gets the size in bytes of a pointer or a handle for the current implementation.
A Int32 containing the number of bytes of a pointer or handle for the current implementation. The value of this property is equal to the number of bytes contained by thenative int
type in the current implementation.
This property is read-only.For more information on the
native int
type, see Partition II of the CLI Specification.
System.IntPtr Structure, System Namespace