UIntPtr 结构
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重要
此 API 不符合 CLS。
表示一个无符号整数,其中位宽度与指针相同。
public value class UIntPtr
public value class UIntPtr : IComparable, IComparable<UIntPtr>, IEquatable<UIntPtr>, IFormattable, System::Runtime::Serialization::ISerializable
public value class UIntPtr : IComparable, IComparable<UIntPtr>, IEquatable<UIntPtr>, ISpanFormattable, System::Runtime::Serialization::ISerializable
public value class UIntPtr : IComparable<UIntPtr>, IEquatable<UIntPtr>, IParsable<UIntPtr>, ISpanParsable<UIntPtr>, System::Numerics::IAdditionOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::IAdditiveIdentity<UIntPtr, UIntPtr>, System::Numerics::IBinaryInteger<UIntPtr>, System::Numerics::IBinaryNumber<UIntPtr>, System::Numerics::IBitwiseOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::IComparisonOperators<UIntPtr, UIntPtr>, System::Numerics::IDecrementOperators<UIntPtr>, System::Numerics::IDivisionOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::IEqualityOperators<UIntPtr, UIntPtr>, System::Numerics::IIncrementOperators<UIntPtr>, System::Numerics::IMinMaxValue<UIntPtr>, System::Numerics::IModulusOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::IMultiplicativeIdentity<UIntPtr, UIntPtr>, System::Numerics::IMultiplyOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::INumber<UIntPtr>, System::Numerics::INumberBase<UIntPtr>, System::Numerics::IShiftOperators<UIntPtr, UIntPtr>, System::Numerics::ISubtractionOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::IUnaryNegationOperators<UIntPtr, UIntPtr>, System::Numerics::IUnaryPlusOperators<UIntPtr, UIntPtr>, System::Numerics::IUnsignedNumber<UIntPtr>, System::Runtime::Serialization::ISerializable
public value class UIntPtr : IEquatable<UIntPtr>, System::Runtime::Serialization::ISerializable
public value class UIntPtr : System::Runtime::Serialization::ISerializable
[System.CLSCompliant(false)]
public struct UIntPtr
[System.CLSCompliant(false)]
public readonly struct UIntPtr : IComparable, IComparable<UIntPtr>, IEquatable<UIntPtr>, IFormattable, System.Runtime.Serialization.ISerializable
[System.CLSCompliant(false)]
public readonly struct UIntPtr : IComparable, IComparable<UIntPtr>, IEquatable<UIntPtr>, ISpanFormattable, System.Runtime.Serialization.ISerializable
[System.CLSCompliant(false)]
public readonly struct UIntPtr : IComparable<UIntPtr>, IEquatable<UIntPtr>, IParsable<UIntPtr>, ISpanParsable<UIntPtr>, System.Numerics.IAdditionOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.IAdditiveIdentity<UIntPtr,UIntPtr>, System.Numerics.IBinaryInteger<UIntPtr>, System.Numerics.IBinaryNumber<UIntPtr>, System.Numerics.IBitwiseOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.IComparisonOperators<UIntPtr,UIntPtr>, System.Numerics.IDecrementOperators<UIntPtr>, System.Numerics.IDivisionOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.IEqualityOperators<UIntPtr,UIntPtr>, System.Numerics.IIncrementOperators<UIntPtr>, System.Numerics.IMinMaxValue<UIntPtr>, System.Numerics.IModulusOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.IMultiplicativeIdentity<UIntPtr,UIntPtr>, System.Numerics.IMultiplyOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.INumber<UIntPtr>, System.Numerics.INumberBase<UIntPtr>, System.Numerics.IShiftOperators<UIntPtr,UIntPtr>, System.Numerics.ISubtractionOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.IUnaryNegationOperators<UIntPtr,UIntPtr>, System.Numerics.IUnaryPlusOperators<UIntPtr,UIntPtr>, System.Numerics.IUnsignedNumber<UIntPtr>, System.Runtime.Serialization.ISerializable
[System.CLSCompliant(false)]
public struct UIntPtr : IEquatable<UIntPtr>, System.Runtime.Serialization.ISerializable
[System.CLSCompliant(false)]
public readonly struct UIntPtr : IEquatable<UIntPtr>, System.Runtime.Serialization.ISerializable
[System.CLSCompliant(false)]
[System.Serializable]
public struct UIntPtr : System.Runtime.Serialization.ISerializable
[System.CLSCompliant(false)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct UIntPtr : System.Runtime.Serialization.ISerializable
[System.CLSCompliant(false)]
public struct UIntPtr : System.Runtime.Serialization.ISerializable
[<System.CLSCompliant(false)>]
type unativeint = struct
[<System.CLSCompliant(false)>]
type unativeint = struct
interface IFormattable
interface ISerializable
[<System.CLSCompliant(false)>]
type unativeint = struct
interface ISpanFormattable
interface IFormattable
interface ISerializable
[<System.CLSCompliant(false)>]
type unativeint = struct
interface IFormattable
interface IParsable<unativeint>
interface ISpanFormattable
interface ISpanParsable<unativeint>
interface IAdditionOperators<unativeint, unativeint, unativeint>
interface IAdditiveIdentity<unativeint, unativeint>
interface IBinaryInteger<unativeint>
interface IBinaryNumber<unativeint>
interface IBitwiseOperators<unativeint, unativeint, unativeint>
interface IComparisonOperators<unativeint, unativeint>
interface IEqualityOperators<unativeint, unativeint>
interface IDecrementOperators<unativeint>
interface IDivisionOperators<unativeint, unativeint, unativeint>
interface IIncrementOperators<unativeint>
interface IModulusOperators<unativeint, unativeint, unativeint>
interface IMultiplicativeIdentity<unativeint, unativeint>
interface IMultiplyOperators<unativeint, unativeint, unativeint>
interface INumber<unativeint>
interface INumberBase<unativeint>
interface ISubtractionOperators<unativeint, unativeint, unativeint>
interface IUnaryNegationOperators<unativeint, unativeint>
interface IUnaryPlusOperators<unativeint, unativeint>
interface IShiftOperators<unativeint, unativeint>
interface IMinMaxValue<unativeint>
interface IUnsignedNumber<unativeint>
interface ISerializable
[<System.CLSCompliant(false)>]
type unativeint = struct
interface ISerializable
[<System.CLSCompliant(false)>]
[<System.Serializable>]
type unativeint = struct
interface ISerializable
[<System.CLSCompliant(false)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type unativeint = struct
interface ISerializable
Public Structure UIntPtr
Public Structure UIntPtr
Implements IComparable, IComparable(Of UIntPtr), IEquatable(Of UIntPtr), IFormattable, ISerializable
Public Structure UIntPtr
Implements IComparable, IComparable(Of UIntPtr), IEquatable(Of UIntPtr), ISerializable, ISpanFormattable
Public Structure UIntPtr
Implements IAdditionOperators(Of UIntPtr, UIntPtr, UIntPtr), IAdditiveIdentity(Of UIntPtr, UIntPtr), IBinaryInteger(Of UIntPtr), IBinaryNumber(Of UIntPtr), IBitwiseOperators(Of UIntPtr, UIntPtr, UIntPtr), IComparable(Of UIntPtr), IComparisonOperators(Of UIntPtr, UIntPtr), IDecrementOperators(Of UIntPtr), IDivisionOperators(Of UIntPtr, UIntPtr, UIntPtr), IEqualityOperators(Of UIntPtr, UIntPtr), IEquatable(Of UIntPtr), IIncrementOperators(Of UIntPtr), IMinMaxValue(Of UIntPtr), IModulusOperators(Of UIntPtr, UIntPtr, UIntPtr), IMultiplicativeIdentity(Of UIntPtr, UIntPtr), IMultiplyOperators(Of UIntPtr, UIntPtr, UIntPtr), INumber(Of UIntPtr), INumberBase(Of UIntPtr), IParsable(Of UIntPtr), ISerializable, IShiftOperators(Of UIntPtr, UIntPtr), ISpanParsable(Of UIntPtr), ISubtractionOperators(Of UIntPtr, UIntPtr, UIntPtr), IUnaryNegationOperators(Of UIntPtr, UIntPtr), IUnaryPlusOperators(Of UIntPtr, UIntPtr), IUnsignedNumber(Of UIntPtr)
Public Structure UIntPtr
Implements IEquatable(Of UIntPtr), ISerializable
Public Structure UIntPtr
Implements ISerializable
- 继承
- 属性
- 实现
-
IComparable IComparable<UIntPtr> IEquatable<UIntPtr> IFormattable ISerializable ISpanFormattable IComparable<TOther> IComparable<TSelf> IEquatable<TOther> IEquatable<TSelf> IParsable<UIntPtr> IParsable<TSelf> ISpanParsable<UIntPtr> ISpanParsable<TSelf> IAdditionOperators<UIntPtr,UIntPtr,UIntPtr> IAdditionOperators<TSelf,TSelf,TSelf> IAdditiveIdentity<UIntPtr,UIntPtr> IAdditiveIdentity<TSelf,TSelf> IBinaryInteger<UIntPtr> IBinaryNumber<UIntPtr> IBinaryNumber<TSelf> IBitwiseOperators<UIntPtr,UIntPtr,UIntPtr> IBitwiseOperators<TSelf,TSelf,TSelf> System.Numerics.IComparisonOperators<UIntPtr,UIntPtr> System.Numerics.IComparisonOperators<TSelf,TSelf> IDecrementOperators<UIntPtr> IDecrementOperators<TSelf> IDivisionOperators<UIntPtr,UIntPtr,UIntPtr> IDivisionOperators<TSelf,TSelf,TSelf> System.Numerics.IEqualityOperators<UIntPtr,UIntPtr> System.Numerics.IEqualityOperators<TSelf,TOther> System.Numerics.IEqualityOperators<TSelf,TSelf> IIncrementOperators<UIntPtr> IIncrementOperators<TSelf> IMinMaxValue<UIntPtr> IModulusOperators<UIntPtr,UIntPtr,UIntPtr> IModulusOperators<TSelf,TSelf,TSelf> IMultiplicativeIdentity<UIntPtr,UIntPtr> IMultiplicativeIdentity<TSelf,TSelf> IMultiplyOperators<UIntPtr,UIntPtr,UIntPtr> IMultiplyOperators<TSelf,TSelf,TSelf> INumber<UIntPtr> INumber<TSelf> INumberBase<UIntPtr> INumberBase<TSelf> System.Numerics.IShiftOperators<UIntPtr,UIntPtr> System.Numerics.IShiftOperators<TSelf,TSelf> ISubtractionOperators<UIntPtr,UIntPtr,UIntPtr> ISubtractionOperators<TSelf,TSelf,TSelf> IUnaryNegationOperators<UIntPtr,UIntPtr> IUnaryNegationOperators<TSelf,TSelf> IUnaryPlusOperators<UIntPtr,UIntPtr> IUnaryPlusOperators<TSelf,TSelf> IUnsignedNumber<UIntPtr>
注解
该 UIntPtr 类型设计为一个整数,其大小与指针相同。 也就是说,此类型的实例应在 32 位进程中为 32 位,在 64 位进程中为 64 位。
该 UIntPtr 类型可由支持指针的语言使用,并且作为引用不同语言之间数据(不支持指针)的常见方法。 UIntPtr 对象还可用于保存句柄。
备注
用作 UIntPtr 指针或句柄容易出错且不安全。 它只是一种整数类型,由于大小相同,可用作指针和句柄的交换格式。 在特定的交换要求之外,例如将数据传递给不支持指针的语言,应使用正确类型的指针来表示指针, SafeHandle 并应用于表示句柄。
此类型实现 ISerializable. 在 .NET 5 及更高版本中,此类型还实现 IFormattable 接口。 在 .NET 7 及更高版本中,此类型还实现、IBinaryInteger<TSelf>IMinMaxValue<TSelf>接口和IUnsignedNumber<TSelf>接口。
从版本 9.0 开始的 C# 中,可以使用内置 nuint
类型来定义本机大小的整数。 此类型在内部由 UIntPtr 类型表示,并提供适用于整数类型的操作和转换。 有关详细信息,请参阅 nint 和 nuint 类型。
在 C# 中,从版本 11 开始,面向 .NET 7 或更高版本运行时时,nuint
是别名,采用与别名相同的方式UInt32uint
。UIntPtr
构造函数
UIntPtr(UInt32) |
使用指定的 32 位无符号整数初始化结构的新实例 UIntPtr 。 |
UIntPtr(UInt64) |
初始化使用指定的 64 位无符号整数的新实例 UIntPtr 。 |
UIntPtr(Void*) |
使用指定的指向未指定类型的指针初始化 UIntPtr 的新实例。 |
字段
Zero |
一个只读字段,表示已初始化为零的无符号整数。 |
属性
MaxValue |
表示 UIntPtr 的最大可能值。 |
MinValue |
表示 UIntPtr 的最小可能值。 |
Size |
获取此实例的大小。 |
方法
运算符
Addition(UIntPtr, Int32) |
向无符号整数添加偏移量。 |
Equality(UIntPtr, UIntPtr) |
确定 UIntPtr 的两个指定的实例是否相等。 |
Explicit(UInt32 to UIntPtr) |
将 32 位无符号整数的值转换成 UIntPtr。 |
Explicit(UInt64 to UIntPtr) |
将 64 位无符号整数的值转换成 UIntPtr。 |
Explicit(UIntPtr to UInt32) |
将指定的 UIntPtr 的值转换为 32 位无符号整数。 |
Explicit(UIntPtr to UInt64) |
将指定的 UIntPtr 的值转换为 64 位无符号整数。 |
Explicit(UIntPtr to Void*) |
将指定的 UIntPtr 的值转换为指向未指定类型的指针。 此 API 不兼容 CLS。 |
Explicit(Void* to UIntPtr) |
将指向未指定类型的指定指针转换为 UIntPtr。 此 API 不兼容 CLS。 |
Inequality(UIntPtr, UIntPtr) |
确定 UIntPtr 的两个指定的实例是否不等。 |
Subtraction(UIntPtr, Int32) |
从无符号整数中减去偏移量。 |
显式接口实现
IBinaryInteger<UIntPtr>.GetByteCount() |
获取将作为其一部分 TryWriteLittleEndian(Span<Byte>, Int32)写入的字节数。 |
IBinaryInteger<UIntPtr>.GetShortestBitLength() |
获取最短两个当前值的补充表示形式的长度(以位为单位)。 |
IBinaryInteger<UIntPtr>.TryWriteBigEndian(Span<Byte>, Int32) |
尝试将当前值(采用大端格式)写入给定范围。 |
IBinaryInteger<UIntPtr>.TryWriteLittleEndian(Span<Byte>, Int32) |
尝试将当前值(以小端格式)写入给定范围。 |
IEquatable<UIntPtr>.Equals(UIntPtr) |
返回一个值,该值指示此实例是否等于另一个无符号整数。 |
ISerializable.GetObjectData(SerializationInfo, StreamingContext) |
使用序列化当前的 SerializationInfo 对象所需的所有数据填充 UIntPtr 对象。 |
适用于
线程安全性
此类型是线程安全的。