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 並提供適合整數類型的作業和轉換。 如需詳細資訊,請參閱 nint 和 nuint 類型。
從 11 版開始,在以 .NET 7 或更新版本執行時間為目標的 C# 中,是 的別名, nuint
uint
與 的別名 UIntPtrUInt32 相同。
建構函式
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 值轉換為未指定的類型指標。 此應用程式開發介面不符合 CLS 標準。 |
Explicit(Void* to UIntPtr) |
將指定的指標轉換為 UIntPtr 的未指定類型。 此應用程式開發介面不符合 CLS 標準。 |
Inequality(UIntPtr, UIntPtr) |
判斷 UIntPtr 的兩個指定執行個體是否不相等。 |
Subtraction(UIntPtr, Int32) |
從不帶正負號的整數減去位移。 |
明確介面實作
適用於
執行緒安全性
此型別具備執行緒安全。
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應