System.UIntPtr Structure

public struct UIntPtr

Base Types

Object
  ValueType
    UIntPtr

Assembly

mscorlib

Library

RuntimeInfrastructure

Summary

An implementation-specific type that is used to represent a pointer or a handle.

Description

The UIntPtr type is designed to be an implementation-sized pointer. An instance of this type is expected to be the size of a native unsigned int for the current implementation.

For more information on the native unsigned int type, see Partition II of the CLI Specification.

[Note: UIntPtr 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.

]

Attributes

CLSCompliantAttribute(false)

See Also

System Namespace

Members

UIntPtr Constructors

UIntPtr(uint) Constructor
UIntPtr(ulong) Constructor

UIntPtr Methods

UIntPtr.Equals Method
UIntPtr.GetHashCode Method
UIntPtr.ToPointer Method
UIntPtr.ToString Method
UIntPtr.ToUInt32 Method
UIntPtr.ToUInt64 Method
UIntPtr.op_Equality Method
UIntPtr.op_Inequality Method

UIntPtr Fields

UIntPtr.Zero Field

UIntPtr Properties

UIntPtr.Size Property


UIntPtr(uint) Constructor

public UIntPtr(uint value);

Summary

Constructs a new UIntPtr structure using the specified UInt32 containing a pointer or a handle.

Parameters

value
A UInt32 containing a pointer or handle.

See Also

System.UIntPtr Structure, System Namespace

UIntPtr(ulong) Constructor

public UIntPtr(ulong value);

Summary

Constructs a new UIntPtr structure using the specified UInt64 containing a pointer or a handle.

Parameters

value
A UInt64 containing a pointer or a handle.

Exceptions

Exception TypeCondition
OverflowExceptionThe current platform is a 32-bit platform and the value of the current instance is greater than System.UInt32.MaxValue.

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.Equals Method

public override bool Equals(object obj);

Summary

Determines whether the current instance and the specified Object represent the same type and value.

Parameters

obj
The Object to compare to the current instance.

Return Value

true if obj is a UIntPtr instance and has the same value as the current instance. If obj is a null reference or is not an instance of UIntPtr , returns false .

Description

[Note: The method overrides System.Object.Equals(System.Object).]

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.GetHashCode Method

public override int GetHashCode();

Summary

Generates a hash code for the current instance.

Return Value

A Int32 containing the hash code for the current instance.

Description

[Note: The algorithm used to generate the hash code is unspecified.]

[Note: This method overrides System.Object.GetHashCode.]

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.ToPointer Method

unsafe public void* ToPointer();

Summary

Converts the value of the current instance to a pointer to void .

Return Value

A pointer to void .

Description

[Note: A pointer to void points to memory containing data of an unspecified type.]

This method is not CLS-compliant. For a CLS-compliant alternative use System.IntPtr.ToPointer.

Attributes

CLSCompliantAttribute(false)

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.ToString Method

public override string ToString();

Summary

Returns a String representation of the value of the current instance.

Return Value

A String representation of the current instance.

Description

[Note: If System.UIntPtr.Size for the current instance is 4, System.UIntPtr.ToString is equivalent to System.UInt32.ToString(); otherwise, this method is equivalent toSystem.UInt64.ToString().

This method overrides System.Object.ToString.

]

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.ToUInt32 Method

public uint ToUInt32();

Summary

Converts the value of the current instance to a UInt32.

Return Value

A UInt32 containing the same value as the current instance.

Exceptions

Exception TypeCondition
OverflowExceptionThe current platform is not a 32-bit platform and the value of the current instance is greater than System.UInt32.MaxValue .

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.ToUInt64 Method

public ulong ToUInt64();

Summary

Converts the value of the current instance to a UInt64.

Return Value

A UInt64 containing the same value as the current instance.

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.op_Equality Method

public static bool operator ==(UIntPtr value1, UIntPtr value2);

Summary

Determines whether the two specified instances of UIntPtr represent the same value.

Parameters

value1
The first UIntPtr to compare for equality.
value2
The second UIntPtr to compare for equality.

Return Value

true if value1 represents the same value as value2; otherwise, false .

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.op_Inequality Method

public static bool operator !=(UIntPtr value1, UIntPtr value2);

Summary

Determines whether two specified instances of UIntPtr represent different values.

Parameters

value1
The first UIntPtr to compare for inequality.
value2
The second UIntPtr to compare for inequality.

Return Value

true if value1 represents a different value than value2; otherwise, false .

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.Zero Field

public static readonly UIntPtr Zero;

Summary

Represents a pointer or handle that has been initialized as zero.

Description

[Note: The value of this field is not null , but is instead a pointer which has been assigned the value zero. Use this field to efficiently determine whether an instance of UIntPtr has been set to a value other than zero. For example, if uip is a UIntPtr instance, using uip != UIntPtr.Zero is more efficient than uip != new UIntPtr(0) to test if uip has been set to a value other than zero.

]

See Also

System.UIntPtr Structure, System Namespace

UIntPtr.Size Property

public static int Size { get; }

Summary

Gets the size in bytes of a pointer or a handle for the current implementation.

Property Value

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 the native unsigned int type in the current implementation.

Description

This property is read-only.

For more information on the native unsigned int type, see Partition II of the CLI Specification.

See Also

System.UIntPtr Structure, System Namespace