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

📅  最后修改于: 2021-05-29 15:25:53             🧑  作者: Mango

MinValue属性或Int64结构的字段用于表示Int64的最小可能值。该字段的值是常数,表示用户无法更改该字段的值。该字段的值为-9223372036854775808 。其十六进制值为0x8000000000000000

句法:

public const long MinValue = -9223372036854775808;

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

例子:

// C# program to illustrate the
// Int64.MinValue Field
using System;
  
class GFG {
      
    // Main Method
    static public void Main()
    {
        // display the Minimum
        // value of Int64 struct
        Console.WriteLine("Minimum Value is: "+
                               Int64.MinValue);
          
        // taking a variable                   
        long var1 = -2382373544;
           
        if(var1.Equals(Int64.MinValue))
        {
            Console.WriteLine("Equal..!!");
            Console.WriteLine("Type of var1 is: {0}",
                                 var1.GetTypeCode());
        }
        else
        {
            Console.WriteLine("Not equal..!!");
            Console.WriteLine("Type of var1 is: {0}",
                                 var1.GetTypeCode());
        }
    }
}
输出:
Minimum Value is: -9223372036854775808
Not equal..!!
Type of var1 is: Int64

参考:

  • https://docs.microsoft.com/zh-cn/dotnet/api/system.int64.minvalue?view=netframework-4.7.2