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, bool>, System::Numerics::IDecrementOperators<UIntPtr>, System::Numerics::IDivisionOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::IEqualityOperators<UIntPtr, UIntPtr, bool>, 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, int, 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 : IComparable<UIntPtr>, IEquatable<UIntPtr>, IParsable<UIntPtr>, ISpanParsable<UIntPtr>, IUtf8SpanParsable<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, bool>, System::Numerics::IDecrementOperators<UIntPtr>, System::Numerics::IDivisionOperators<UIntPtr, UIntPtr, UIntPtr>, System::Numerics::IEqualityOperators<UIntPtr, UIntPtr, bool>, 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, int, 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,bool>, System.Numerics.IDecrementOperators<UIntPtr>, System.Numerics.IDivisionOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.IEqualityOperators<UIntPtr,UIntPtr,bool>, 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,int,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 readonly struct UIntPtr : IComparable<UIntPtr>, IEquatable<UIntPtr>, IParsable<UIntPtr>, ISpanParsable<UIntPtr>, IUtf8SpanParsable<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,bool>, System.Numerics.IDecrementOperators<UIntPtr>, System.Numerics.IDivisionOperators<UIntPtr,UIntPtr,UIntPtr>, System.Numerics.IEqualityOperators<UIntPtr,UIntPtr,bool>, 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,int,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, bool>
interface IEqualityOperators<unativeint, unativeint, bool>
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, int, unativeint>
interface IMinMaxValue<unativeint>
interface IUnsignedNumber<unativeint>
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, bool>
interface IEqualityOperators<unativeint, unativeint, bool>
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 IUtf8SpanFormattable
interface IUtf8SpanParsable<unativeint>
interface IShiftOperators<unativeint, int, unativeint>
interface IMinMaxValue<unativeint>
interface IUnsignedNumber<unativeint>
interface ISerializable
[<System.CLSCompliant(false)>]
type unativeint = struct
interface IFormattable
interface IParsable<unativeint>
interface ISpanFormattable
interface ISpanParsable<unativeint>
interface IUtf8SpanFormattable
interface IUtf8SpanParsable<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, bool>
interface IEqualityOperators<unativeint, unativeint, bool>
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, int, 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, Boolean), IDecrementOperators(Of UIntPtr), IDivisionOperators(Of UIntPtr, UIntPtr, UIntPtr), IEqualityOperators(Of UIntPtr, UIntPtr, Boolean), 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, Integer, UIntPtr), ISpanParsable(Of UIntPtr), ISubtractionOperators(Of UIntPtr, UIntPtr, UIntPtr), IUnaryNegationOperators(Of UIntPtr, UIntPtr), IUnaryPlusOperators(Of UIntPtr, UIntPtr), IUnsignedNumber(Of UIntPtr)
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, Boolean), IDecrementOperators(Of UIntPtr), IDivisionOperators(Of UIntPtr, UIntPtr, UIntPtr), IEqualityOperators(Of UIntPtr, UIntPtr, Boolean), 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, Integer, UIntPtr), ISpanParsable(Of UIntPtr), ISubtractionOperators(Of UIntPtr, UIntPtr, UIntPtr), IUnaryNegationOperators(Of UIntPtr, UIntPtr), IUnaryPlusOperators(Of UIntPtr, UIntPtr), IUnsignedNumber(Of UIntPtr), IUtf8SpanParsable(Of UIntPtr)
Public Structure UIntPtr
Implements IEquatable(Of UIntPtr), ISerializable
Public Structure UIntPtr
Implements ISerializable
- 繼承
- 屬性
- 實作
-
IComparable IComparable<UIntPtr> IEquatable<UIntPtr> IFormattable ISerializable ISpanFormattable IComparable<TSelf> 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> IComparisonOperators<UIntPtr,UIntPtr,Boolean> IComparisonOperators<TSelf,TSelf,Boolean> IDecrementOperators<UIntPtr> IDecrementOperators<TSelf> IDivisionOperators<UIntPtr,UIntPtr,UIntPtr> IDivisionOperators<TSelf,TSelf,TSelf> IEqualityOperators<UIntPtr,UIntPtr,Boolean> IEqualityOperators<TSelf,TOther,TResult> IEqualityOperators<TSelf,TSelf,Boolean> 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> IShiftOperators<UIntPtr,Int32,UIntPtr> IShiftOperators<TSelf,Int32,TSelf> ISubtractionOperators<UIntPtr,UIntPtr,UIntPtr> ISubtractionOperators<TSelf,TSelf,TSelf> IUnaryNegationOperators<UIntPtr,UIntPtr> IUnaryNegationOperators<TSelf,TSelf> IUnaryPlusOperators<UIntPtr,UIntPtr> IUnaryPlusOperators<TSelf,TSelf> IUnsignedNumber<UIntPtr> IUtf8SpanFormattable IUtf8SpanParsable<UIntPtr> IUtf8SpanParsable<TSelf>
備註
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 類型表示,並提供適用於整數類型的作業和轉換。 如需詳細資訊,請參閱
從第 11 版開始,在以 .NET 7 或更新版本運行時間為目標的 C# 中,nuint
是 UIntPtr 的別名,uint
是 UInt32的別名。
建構函式
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) |
從不帶正負號的整數減去位移。 |
明確介面實作
適用於
執行緒安全性
此類型是安全線程。