📜  C#中的UInt32.MinValue字段(带示例)

📅  最后修改于: 2021-05-29 23:37:37             🧑  作者: Mango

UInt32 Struct的MinValue字段用于表示32位无符号整数(即uint数据类型)的最小可能值。该字段的值是常数,表示用户无法更改该字段的值。该字段的值为0

句法:

public const uint MinValue = 0;

返回值:该字段始终返回0。

例子:

// C# program to illustrate the
// UInt32.MinValue field
using System;
  
class GFG {
  
    // Main Method
    static public void Main()
    {
        // display the Minimum value of UInt32 struct
        Console.WriteLine("Minimum Value is: " + UInt32.MinValue);
  
        // Taking an array of the 
        // unsigned long integer 
        // i.e UInt64 data type
        ulong[] num = {34326, 32434, 12335546464565, 3434234786};
  
        // taking variable of UInt32 type
        uint mynum;
  
        foreach(ulong n in num)
        {
  
            if (n >= UInt32.MinValue && n <= UInt32.MaxValue) {
  
                // using the method of Convert class
                mynum = Convert.ToUInt32(n);
  
                Console.WriteLine("Conversion is Possible.");
            }
  
            else {
                Console.WriteLine("Not Possible");
            }
        }
    }
}

输出:

Minimum Value is: 0
Conversion is Possible.
Conversion is Possible.
Not Possible
Conversion is Possible.

参考:

  • https://docs.microsoft.com/zh-cn/dotnet/api/system.uint32.minvalue?view=netstandard-2.1