當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


C# UInt32.MinValue用法及代碼示例


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.

參考:



相關用法


注:本文由純淨天空篩選整理自ankita_saini大神的英文原創作品 UInt32.MinValue Field in C# with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。