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


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。