UInt32 结构

定义

重要

此 API 不符合 CLS。

表示 32 位无符号整数。Represents a 32-bit unsigned integer.

public value class UInt32 : IComparable, IComparable<System::UInt32>, IConvertible, IEquatable<System::UInt32>, IFormattable
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct UInt32 : IComparable, IComparable<uint>, IConvertible, IEquatable<uint>, IFormattable
type uint32 = struct
    interface IFormattable
    interface IConvertible
Public Structure UInt32
Implements IComparable, IComparable(Of UInteger), IConvertible, IEquatable(Of UInteger), IFormattable
继承
UInt32
属性
实现

注解

UInt32 值类型表示其值范围从0到4294967295的无符号整数。The UInt32 value type represents unsigned integers with values ranging from 0 to 4,294,967,295.

重要

UInt32 类型不符合 CLS。The UInt32 type is not CLS-compliant. 符合 CLS 的替代类型为 Int64The CLS-compliant alternative type is Int64. 可以改为使用 Int32 来替换介于零到 MaxValue之间的 UInt32 值。Int32 can be used instead to replace a UInt32 value that ranges from zero to MaxValue. 有关 CLS 遵从性的详细信息,请参阅语言独立性和与语言无关的组件For more information about CLS compliance, see Language Independence and Language-Independent Components.

UInt32 提供了一些方法,用于比较此类型的实例,将实例的值转换为其 String 表示形式,并将数字的 String 表示形式转换为此类型的实例。UInt32 provides methods to compare instances of this type, convert the value of an instance to its String representation, and convert the String representation of a number to an instance of this type.

有关格式规范代码如何控制值类型的 String 表示形式的信息,请参阅格式设置类型For information about how format specification codes control the String representation of value types, see Formatting Types.

字段

MaxValue

表示 UInt32的最大可能值。Represents the largest possible value of UInt32. 此字段为常数。This field is constant.

MinValue

表示 UInt32 的最小可能值。Represents the smallest possible value of UInt32. 此字段为常数。This field is constant.

方法

CompareTo(Object)

将此实例与指定对象进行比较并返回一个对二者的相对值的指示。Compares this instance to a specified object and returns an indication of their relative values.

CompareTo(UInt32)

将此实例与指定的 32 位无符号整数进行比较并返回对其相对值的指示。Compares this instance to a specified 32-bit unsigned integer and returns an indication of their relative values.

Equals(Object)

返回一个值,该值指示此实例是否等于指定的对象。Returns a value indicating whether this instance is equal to a specified object.

Equals(UInt32)

返回一个值,该值指示此实例是否与指定的 UInt32 相等。Returns a value indicating whether this instance is equal to a specified UInt32.

GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

GetTypeCode()

返回值类型 TypeCodeUInt32Returns the TypeCode for value type UInt32.

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

将指定样式和区域性特定格式的数字的范围表示形式转换为其等效的 32 位无符号整数。Converts the span representation of a number in a specified style and culture-specific format to its 32-bit unsigned integer equivalent.

Parse(String)

将数字的字符串表示形式转换为它的等效 32 位无符号整数。Converts the string representation of a number to its 32-bit unsigned integer equivalent.

Parse(String, IFormatProvider)

将指定区域性特定格式的数字的字符串表示形式转换为它的等效 32 位无符号整数。Converts the string representation of a number in a specified culture-specific format to its 32-bit unsigned integer equivalent.

Parse(String, NumberStyles)

将指定样式的数字的字符串表示形式转换为它的等效 32 位无符号整数。Converts the string representation of a number in a specified style to its 32-bit unsigned integer equivalent.

Parse(String, NumberStyles, IFormatProvider)

将指定样式和区域性特定格式的数字的字符串表示形式转换为它的等效 32 位无符号整数。Converts the string representation of a number in a specified style and culture-specific format to its 32-bit unsigned integer equivalent.

ToString()

将此实例的数值转换为其等效的字符串表示形式。Converts the numeric value of this instance to its equivalent string representation.

ToString(IFormatProvider)

使用指定的区域性特定格式信息,将此实例的数值转换为它的等效字符串表示形式。Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

ToString(String)

使用指定的格式将此实例的数值转换为它的等效字符串表示形式。Converts the numeric value of this instance to its equivalent string representation using the specified format.

ToString(String, IFormatProvider)

使用指定的格式和区域性特定格式信息,将此实例的数值转换为它的等效字符串表示形式。Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

尝试将当前无符号整数数字实例的值的格式设置为提供的字符范围。Tries to format the value of the current unsigned integer number instance into the provided span of characters.

TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, UInt32)

尝试将指定样式和区域性特定格式的数字的范围表示形式转换为其等效的 32 位无符号整数。Tries to convert the span representation of a number in a specified style and culture-specific format to its 32-bit unsigned integer equivalent. 一个指示转换是否成功的返回值。A return value indicates whether the conversion succeeded or failed.

TryParse(ReadOnlySpan<Char>, UInt32)

尝试将数字的范围表示形式转换为其等效的 32 位无符号整数。Tries to convert the span representation of a number to its 32-bit unsigned integer equivalent. 一个指示转换是否成功的返回值。A return value indicates whether the conversion succeeded or failed.

TryParse(String, NumberStyles, IFormatProvider, UInt32)

尝试将数字的指定样式和区域性特定格式的字符串表示形式转换为其等效的 32 位无符号整数。Tries to convert the string representation of a number in a specified style and culture-specific format to its 32-bit unsigned integer equivalent. 一个指示转换是否成功的返回值。A return value indicates whether the conversion succeeded or failed.

TryParse(String, UInt32)

尝试将数字的字符串表示形式转换为等效的 32 位无符号整数。Tries to convert the string representation of a number to its 32-bit unsigned integer equivalent. 一个指示转换是否成功的返回值。A return value indicates whether the conversion succeeded or failed.

显式界面实现

IComparable.CompareTo(Object)

将此实例与指定对象进行比较并返回一个对二者的相对值的指示。Compares this instance to a specified object and returns an indication of their relative values.

IConvertible.GetTypeCode()

返回值类型 TypeCodeUInt32Returns the TypeCode for value type UInt32.

IConvertible.ToBoolean(IFormatProvider)

有关此成员的说明,请参见 ToBoolean(IFormatProvider)For a description of this member, see ToBoolean(IFormatProvider).

IConvertible.ToByte(IFormatProvider)

有关此成员的说明,请参见 ToByte(IFormatProvider)For a description of this member, see ToByte(IFormatProvider).

IConvertible.ToChar(IFormatProvider)

有关此成员的说明,请参见 ToChar(IFormatProvider)For a description of this member, see ToChar(IFormatProvider).

IConvertible.ToDateTime(IFormatProvider)

不支持此转换。This conversion is not supported. 尝试使用此方法将引发 InvalidCastExceptionAttempting to use this method throws an InvalidCastException.

IConvertible.ToDecimal(IFormatProvider)

有关此成员的说明,请参见 ToDecimal(IFormatProvider)For a description of this member, see ToDecimal(IFormatProvider).

IConvertible.ToDouble(IFormatProvider)

有关此成员的说明,请参见 ToDouble(IFormatProvider)For a description of this member, see ToDouble(IFormatProvider).

IConvertible.ToInt16(IFormatProvider)

有关此成员的说明,请参见 ToInt16(IFormatProvider)For a description of this member, see ToInt16(IFormatProvider).

IConvertible.ToInt32(IFormatProvider)

有关此成员的说明,请参见 ToInt32(IFormatProvider)For a description of this member, see ToInt32(IFormatProvider).

IConvertible.ToInt64(IFormatProvider)

有关此成员的说明,请参见 ToInt64(IFormatProvider)For a description of this member, see ToInt64(IFormatProvider).

IConvertible.ToSByte(IFormatProvider)

有关此成员的说明,请参见 ToSByte(IFormatProvider)For a description of this member, see ToSByte(IFormatProvider).

IConvertible.ToSingle(IFormatProvider)

有关此成员的说明,请参见 ToSingle(IFormatProvider)For a description of this member, see ToSingle(IFormatProvider).

IConvertible.ToType(Type, IFormatProvider)

有关此成员的说明,请参见 ToType(Type, IFormatProvider)For a description of this member, see ToType(Type, IFormatProvider).

IConvertible.ToUInt16(IFormatProvider)

有关此成员的说明,请参见 ToUInt16(IFormatProvider)For a description of this member, see ToUInt16(IFormatProvider).

IConvertible.ToUInt32(IFormatProvider)

有关此成员的说明,请参见 ToUInt32(IFormatProvider)For a description of this member, see ToUInt32(IFormatProvider).

IConvertible.ToUInt64(IFormatProvider)

有关此成员的说明,请参见 ToUInt64(IFormatProvider)For a description of this member, see ToUInt64(IFormatProvider).

适用于

线程安全性

此类型的所有成员都是线程安全的。All members of this type are thread safe. 看似修改实例状态的成员实际上返回用新值初始化的新实例。Members that appear to modify instance state actually return a new instance initialized with the new value. 与任何其他类型一样,读取和写入包含此类型的实例的共享变量时,必须通过锁保护以保证线程安全。As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.

另请参阅