IntPtr Constructors

Definition

初始化 IntPtr 的新实例。Initializes a new instance of IntPtr.

Overloads

IntPtr(Int32)

使用指定的 32 位指针或句柄初始化 IntPtr 的新实例。Initializes a new instance of IntPtr using the specified 32-bit pointer or handle.

IntPtr(Int64)

使用指定的 64 位指针初始化 IntPtr 的新实例。Initializes a new instance of IntPtr using the specified 64-bit pointer.

IntPtr(Void*)

使用指定的指向未指定类型的指针初始化 IntPtr 的新实例。Initializes a new instance of IntPtr using the specified pointer to an unspecified type.

IntPtr(Int32)

使用指定的 32 位指针或句柄初始化 IntPtr 的新实例。Initializes a new instance of IntPtr using the specified 32-bit pointer or handle.

public:
 IntPtr(int value);
public IntPtr (int value);
new nativeint : int -> nativeint
Public Sub New (value As Integer)

Parameters

value
Int32

32 位有符号整数中包含的指针或句柄。A pointer or handle contained in a 32-bit signed integer.

IntPtr(Int64)

使用指定的 64 位指针初始化 IntPtr 的新实例。Initializes a new instance of IntPtr using the specified 64-bit pointer.

public:
 IntPtr(long value);
public IntPtr (long value);
new nativeint : int64 -> nativeint
Public Sub New (value As Long)

Parameters

value
Int64

64 位有符号整数中包含的指针或句柄。A pointer or handle contained in a 64-bit signed integer.

Exceptions

在 32 位的平台上,value 太大或太小,无法表示为 IntPtrOn a 32-bit platform, value is too large or too small to represent as an IntPtr.

Remarks

仅当 value 的值需要比当前平台支持的更多的位数时,才会引发异常。An exception is only thrown if the value of value requires more bits than the current platform supports.

IntPtr(Void*)

Important

This API is not CLS-compliant.

使用指定的指向未指定类型的指针初始化 IntPtr 的新实例。Initializes a new instance of IntPtr using the specified pointer to an unspecified type.

public:
 IntPtr(void* value);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
public IntPtr (void* value);
[System.CLSCompliant(false)]
public IntPtr (void* value);
new nativeint : nativeptr<unit> -> nativeint

Parameters

value
Void*

指向未指定类型的指针。A pointer to an unspecified type.

Attributes

See also

Applies to