mscorlib(4.0.0.0) API with additions
System.IntPtr Struct Reference

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

Inheritance diagram for System.IntPtr:
[legend]
Collaboration diagram for System.IntPtr:
[legend]

Public Member Functions

internal unsafe bool IsNull ()
 
unsafe IntPtr (int value)
 Initializes a new instance of T:System.IntPtr using the specified 32-bit pointer or handle. More...
 
unsafe IntPtr (long value)
 Initializes a new instance of T:System.IntPtr using the specified 64-bit pointer. More...
 
unsafe IntPtr (void *value)
 Initializes a new instance of T:System.IntPtr using the specified pointer to an unspecified type. More...
 
unsafe void ISerializable. GetObjectData (SerializationInfo info, StreamingContext context)
 Populates a T:System.Runtime.Serialization.SerializationInfo object with the data needed to serialize the current T:System.IntPtr object. More...
 
unsafe override bool Equals (object obj)
 Returns a value indicating whether this instance is equal to a specified object. More...
 
unsafe override int GetHashCode ()
 Returns the hash code for this instance. More...
 
unsafe int ToInt32 ()
 Converts the value of this instance to a 32-bit signed integer. More...
 
unsafe long ToInt64 ()
 Converts the value of this instance to a 64-bit signed integer. More...
 
unsafe override string ToString ()
 Converts the numeric value of the current T:System.IntPtr object to its equivalent string representation. More...
 
unsafe string ToString (string format)
 Converts the numeric value of the current T:System.IntPtr object to its equivalent string representation. More...
 
unsafe void * ToPointer ()
 Converts the value of this instance to a pointer to an unspecified type. More...
 

Static Public Member Functions

static operator IntPtr (int value)
 Converts the value of a 32-bit signed integer to an T:System.IntPtr. More...
 
static operator IntPtr (long value)
 Converts the value of a 64-bit signed integer to an T:System.IntPtr. More...
 
static unsafe operator IntPtr (void *value)
 Converts the specified pointer to an unspecified type to an T:System.IntPtr. More...
 
static unsafe operator void * (IntPtr value)
 Converts the value of the specified T:System.IntPtr to a pointer to an unspecified type. More...
 
static unsafe operator int (IntPtr value)
 Converts the value of the specified T:System.IntPtr to a 32-bit signed integer. More...
 
static unsafe operator long (IntPtr value)
 Converts the value of the specified T:System.IntPtr to a 64-bit signed integer. More...
 
static unsafe bool operator== (IntPtr value1, IntPtr value2)
 Determines whether two specified instances of T:System.IntPtr are equal. More...
 
static unsafe bool operator != (IntPtr value1, IntPtr value2)
 Determines whether two specified instances of T:System.IntPtr are not equal. More...
 
static IntPtr Add (IntPtr pointer, int offset)
 Adds an offset to the value of a pointer. More...
 
static IntPtr operator+ (IntPtr pointer, int offset)
 Adds an offset to the value of a pointer. More...
 
static IntPtr Subtract (IntPtr pointer, int offset)
 Subtracts an offset from the value of a pointer. More...
 
static IntPtr operator - (IntPtr pointer, int offset)
 Subtracts an offset from the value of a pointer. More...
 

Static Public Attributes

static readonly IntPtr Zero
 A read-only field that represents a pointer or handle that has been initialized to zero. More...
 

Properties

static int Size [get]
 Gets the size of this instance. More...
 

Detailed Description

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

Definition at line 14 of file IntPtr.cs.

Constructor & Destructor Documentation

◆ IntPtr() [1/3]

unsafe System.IntPtr.IntPtr ( int  value)

Initializes a new instance of T:System.IntPtr using the specified 32-bit pointer or handle.

Parameters
valueA pointer or handle contained in a 32-bit signed integer.

Definition at line 50 of file IntPtr.cs.

◆ IntPtr() [2/3]

unsafe System.IntPtr.IntPtr ( long  value)

Initializes a new instance of T:System.IntPtr using the specified 64-bit pointer.

Parameters
valueA pointer or handle contained in a 64-bit signed integer.
Exceptions
T:System.OverflowExceptionOn a 32-bit platform, value is too large or too small to represent as an T:System.IntPtr.

Definition at line 62 of file IntPtr.cs.

◆ IntPtr() [3/3]

unsafe System.IntPtr.IntPtr ( void *  value)

Initializes a new instance of T:System.IntPtr using the specified pointer to an unspecified type.

Parameters
valueA pointer to an unspecified type.

Definition at line 73 of file IntPtr.cs.

Member Function Documentation

◆ Add()

static IntPtr System.IntPtr.Add ( IntPtr  pointer,
int  offset 
)
static

Adds an offset to the value of a pointer.

Parameters
pointerThe pointer to add the offset to.
offsetThe offset to add.
Returns
A new pointer that reflects the addition of offset to pointer .

Definition at line 271 of file IntPtr.cs.

◆ Equals()

unsafe override bool System.IntPtr.Equals ( object  obj)

Returns a value indicating whether this instance is equal to a specified object.

Parameters
objAn object to compare with this instance or null.
Returns
true if obj is an instance of T:System.IntPtr and equals the value of this instance; otherwise, false.

Definition at line 110 of file IntPtr.cs.

◆ GetHashCode()

unsafe override int System.IntPtr.GetHashCode ( )

Returns the hash code for this instance.

Returns
A 32-bit signed integer hash code.

Definition at line 123 of file IntPtr.cs.

◆ GetObjectData()

unsafe void ISerializable. System.IntPtr.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)

Populates a T:System.Runtime.Serialization.SerializationInfo object with the data needed to serialize the current T:System.IntPtr object.

Parameters
infoThe T:System.Runtime.Serialization.SerializationInfo object to populate with data.
contextThe destination for this serialization. (This parameter is not used; specify null.)
Exceptions
T:System.ArgumentNullExceptioninfo is null.

Implements System.Runtime.Serialization.ISerializable.

Definition at line 95 of file IntPtr.cs.

◆ operator !=()

static unsafe bool System.IntPtr.operator != ( IntPtr  value1,
IntPtr  value2 
)
static

Determines whether two specified instances of T:System.IntPtr are not equal.

Parameters
value1The first pointer or handle to compare.
value2The second pointer or handle to compare.
Returns
true if value1 does not equal value2 ; otherwise, false.

Definition at line 260 of file IntPtr.cs.

◆ operator -()

static IntPtr System.IntPtr.operator - ( IntPtr  pointer,
int  offset 
)
static

Subtracts an offset from the value of a pointer.

Parameters
pointerThe pointer to subtract the offset from.
offsetThe offset to subtract.
Returns
A new pointer that reflects the subtraction of offset from pointer .

Definition at line 304 of file IntPtr.cs.

◆ operator int()

static unsafe System.IntPtr.operator int ( IntPtr  value)
explicitstatic

Converts the value of the specified T:System.IntPtr to a 32-bit signed integer.

Parameters
valueThe pointer or handle to convert.
Returns
The contents of value .
Exceptions
T:System.OverflowExceptionOn a 64-bit platform, the value of value is too large to represent as a 32-bit signed integer.

Definition at line 221 of file IntPtr.cs.

◆ operator IntPtr() [1/3]

static System.IntPtr.operator IntPtr ( int  value)
explicitstatic

Converts the value of a 32-bit signed integer to an T:System.IntPtr.

Parameters
valueA 32-bit signed integer.
Returns
A new instance of T:System.IntPtr initialized to value .

Definition at line 176 of file IntPtr.cs.

◆ operator IntPtr() [2/3]

static System.IntPtr.operator IntPtr ( long  value)
explicitstatic

Converts the value of a 64-bit signed integer to an T:System.IntPtr.

Parameters
valueA 64-bit signed integer.
Returns
A new instance of T:System.IntPtr initialized to value .
Exceptions
T:System.OverflowExceptionOn a 32-bit platform, value is too large to represent as an T:System.IntPtr.

Definition at line 187 of file IntPtr.cs.

◆ operator IntPtr() [3/3]

static unsafe System.IntPtr.operator IntPtr ( void *  value)
explicitstatic

Converts the specified pointer to an unspecified type to an T:System.IntPtr.

Parameters
valueA pointer to an unspecified type.
Returns
A new instance of T:System.IntPtr initialized to value .

Definition at line 199 of file IntPtr.cs.

◆ operator long()

static unsafe System.IntPtr.operator long ( IntPtr  value)
explicitstatic

Converts the value of the specified T:System.IntPtr to a 64-bit signed integer.

Parameters
valueThe pointer or handle to convert.
Returns
The contents of value .

Definition at line 232 of file IntPtr.cs.

◆ operator void *()

static unsafe System.IntPtr.operator void * ( IntPtr  value)
explicitstatic

Converts the value of the specified T:System.IntPtr to a pointer to an unspecified type.

Parameters
valueThe pointer or handle to convert.
Returns
The contents of value .

Definition at line 210 of file IntPtr.cs.

◆ operator+()

static IntPtr System.IntPtr.operator+ ( IntPtr  pointer,
int  offset 
)
static

Adds an offset to the value of a pointer.

Parameters
pointerThe pointer to add the offset to.
offsetThe offset to add.
Returns
A new pointer that reflects the addition of offset to pointer .

Definition at line 282 of file IntPtr.cs.

◆ operator==()

static unsafe bool System.IntPtr.operator== ( IntPtr  value1,
IntPtr  value2 
)
static

Determines whether two specified instances of T:System.IntPtr are equal.

Parameters
value1The first pointer or handle to compare.
value2The second pointer or handle to compare.
Returns
true if value1 equals value2 ; otherwise, false.

Definition at line 246 of file IntPtr.cs.

◆ Subtract()

static IntPtr System.IntPtr.Subtract ( IntPtr  pointer,
int  offset 
)
static

Subtracts an offset from the value of a pointer.

Parameters
pointerThe pointer to subtract the offset from.
offsetThe offset to subtract.
Returns
A new pointer that reflects the subtraction of offset from pointer .

Definition at line 293 of file IntPtr.cs.

◆ ToInt32()

unsafe int System.IntPtr.ToInt32 ( )

Converts the value of this instance to a 32-bit signed integer.

Returns
A 32-bit signed integer equal to the value of this instance.
Exceptions
T:System.OverflowExceptionOn a 64-bit platform, the value of this instance is too large or too small to represent as a 32-bit signed integer.

Definition at line 135 of file IntPtr.cs.

◆ ToInt64()

unsafe long System.IntPtr.ToInt64 ( )

Converts the value of this instance to a 64-bit signed integer.

Returns
A 64-bit signed integer equal to the value of this instance.

Definition at line 147 of file IntPtr.cs.

◆ ToPointer()

unsafe void* System.IntPtr.ToPointer ( )

Converts the value of this instance to a pointer to an unspecified type.

Returns
A pointer to T:System.Void; that is, a pointer to memory containing data of an unspecified type.

Definition at line 315 of file IntPtr.cs.

◆ ToString() [1/2]

unsafe override string System.IntPtr.ToString ( )

Converts the numeric value of the current T:System.IntPtr object to its equivalent string representation.

Returns
The string representation of the value of this instance.

Definition at line 156 of file IntPtr.cs.

◆ ToString() [2/2]

unsafe string System.IntPtr.ToString ( string  format)

Converts the numeric value of the current T:System.IntPtr object to its equivalent string representation.

Parameters
formatA format specification that governs how the current T:System.IntPtr object is converted.
Returns
The string representation of the value of the current T:System.IntPtr object.

Definition at line 166 of file IntPtr.cs.

Member Data Documentation

◆ Zero

readonly IntPtr System.IntPtr.Zero
static

A read-only field that represents a pointer or handle that has been initialized to zero.

Definition at line 20 of file IntPtr.cs.

Property Documentation

◆ Size

int System.IntPtr.Size
staticget

Gets the size of this instance.

Returns
The size of a pointer or handle in this process, measured in bytes. The value of this property is 4 in a 32-bit process, and 8 in a 64-bit process. You can define the process type by setting the /platform switch when you compile your code with the C# and Visual Basic compilers.

Definition at line 27 of file IntPtr.cs.


The documentation for this struct was generated from the following file: