当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


C# Int32.MinValue用法及代码示例


MinValue属性或Int32 Struct的字段用于表示Int32的最小可能值。该字段的值是常量,表示用户无法更改该字段的值。该字段的值为-2,147,483,648。它的十六进制值为0x80000000。

用法:

public const int MinValue = -2147483648;

返回值:该字段始终返回-2147483648。


例:

// C# program to illustrate the 
// Int32.MinValue field 
using System; 
  
class GFG { 
  
    // Main Method 
    static public void Main() 
    { 
        // display the Minimum value of Int32 struct 
        Console.WriteLine("Minimum Value is:"+ 
                               Int32.MinValue); 
  
        // Taking an array of long i.e Int64 data type 
        long []num = {346, 434443, -33445, -442343263647}; 
  
        // taking variable of Int32 type 
        int mynum; 
        foreach(long n in num) 
        { 
  
            if(n >= Int32.MinValue && n <= Int32.MaxValue) 
            { 
  
                // using the method of Convert class 
                mynum = Convert.ToInt32(n); 
                Console.WriteLine("Conversion is Possible."); 
            } 
              
            else
            { 
                Console.WriteLine("Not Possible"); 
            } 
        } 
          
    } 
}

输出:

Minimum Value is:-2147483648
Conversion is Possible.
Conversion is Possible.
Conversion is Possible.
Not Possible

参考:



相关用法


注:本文由纯净天空筛选整理自ankita_saini大神的英文原创作品 Int32.MinValue Field in C# with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。