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


C# Int64.MaxValue用法及代码示例


Int64 Struct的MaxValue字段或属性用于表示Int64的最大值。该字段的值是常量,表示用户无法更改该字段的值。该字段的值为9223372036854775807。其十六进制值为0x7FFFFFFFFFFFFFFF。

用法:

public const long MaxValue = 9223372036854775807;

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


例:

// C# program to illustrate the 
// Int64.MaxValue Field 
using System; 
  
class GFG { 
      
    // Main Method 
    static public void Main() 
    { 
        // display the Maximum 
        // value of Int64 struct 
        Console.WriteLine("Maximum Value is:"+ 
                            Int64.MaxValue); 
          
        // taking a variable                  
        long var1 = 93422337368375807; 
          
        if(var1.Equals(Int64.MaxValue)) 
        { 
            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()); 
        } 
    } 
}
输出:
Maximum Value is:9223372036854775807
Not equal..!!
Type of var1 is:Int64

参考:



相关用法


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