在C#中, UInt32结构用于表示32位无符号整数(也称为int数据类型), 范围从0到4, 294, 967, 295。它还提供了不同类型的方法来比较此类型的实例, 将实例的值转换为其String表示形式, 将数字的String表示形式转换为该类型的实例等。此结构在系统命名空间。 UInt32结构继承了ValueType类, 该类继承了对象类别.
领域
| 领域 | 描述 | 
|---|---|
| 最大值 | 表示UInt32的最大可能值。该字段是恒定的。 | 
| 最小值 | 表示UInt32的最小可能值。该字段是恒定的。 |  
  
例子:
//C# program to illustrate the 
//fields of UInt32 struct
using System;
  
class GFG {
  
     //Main Method
     static public void Main()
     {
  
         //Unsigned 32-bit integer
         uint val = 4294967295;
  
         //Checking the unsigned integer
         if (val.Equals(UInt32.MinValue)) 
         {
             Console.WriteLine( "Equal to MinValue!" );
         }
  
         else if (val.Equals(UInt32.MaxValue)) 
         {
             Console.WriteLine( "Equal to MaxValue!" );
         }
         else {
             Console.WriteLine( "Not Equal!" );
         }
     }
} 
 
 
输出如下:
Equal to MaxValue! 
 
 
 
 
 
方法
| 方法 | 描述 | 
|---|---|
| CompareTo() | 将当前实例与指定的对象或UInt32比较, 并返回其相对值的指示。 | 
| Equals() | 返回一个值, 该值显示当前实例是否等于指定的对象或UInt32。 | 
| GetHashCode() | 返回此实例的哈希码。 | 
| GetTypeCode() | 返回值类型UInt32的TypeCode。 | 
| Parse() | 将数字的字符串表示形式转换为其等效的32位无符号整数。 | 
| ToString() | 将此实例的数值转换为其等效的字符串表示形式。 | 
| TryParse() | 尝试将数字的字符串表示形式转换为其等效的32位无符号整数。返回值指示转换是成功还是失败。 | 
例子:
//C# program to illustrate how to get the
//hash code of the 32-bit Unsigned integer
using System;
  
class GFG {
  
     //Main Method
     static public void Main()
     {
  
         //UInt32 variable
         uint myval = 33453242;
  
         //Get the hash code
         //Using GetHashCode Method
         int res = myval.GetHashCode();
         Console.WriteLine( "The hash code of myval is: {0}" , res);
     }
} 
 
 
输出如下:
The hash code of myval is: 33453242 
 
 
参考:
- https://docs.microsoft.com/en-us/dotnet/api/system.uint32?view=netframework-4.8
 

![从字法上最小长度N的排列,使得对于正好为K个索引,a[i] a[i]+1](https://www.lsbin.com/wp-content/themes/begin%20lts/img/loading.png)