In C#, Int64 Struct is used to represent 64-bit signed integer(also termed as long data type) starting from range -9,223,372,036,854,775,808 to +9, 223,372,036,854,775,807. It provides different types of method to perform various operations. A user can perform the mathematical operation like addition, subtraction, multiplication, etc. on Int64 type. It supports bitwise operations like AND, OR, XOR, etc. It provides full support for standard and custom numeric format strings. The user can also call the methods of Convert and Math class to perform operations on Int64 value. Int64 struct inherits the ValueType class which inherits the Object class.
Fields
Fields |
Description |
MaxValue |
This field is used to represent the largest possible value of an Int64. This field is constant. |
MinValue |
This field is used to represent the smallest possible value of an Int64. This field is constant. |
Example 1:
using System;
class GFG {
static public void Main()
{
Int64 var1 = 89;
Int64 var2 = 50;
Int64 var3 = 10;
Console.WriteLine( "Value 1: {0}" , var1);
Console.WriteLine( "Value 2: {0}" , var2);
Console.WriteLine( "Value 3: {0}" , var3);
Console.WriteLine( "Maximum Value: {0}" ,
Int64.MaxValue);
Console.WriteLine( "Minimum Value: {0}" ,
Int64.MinValue);
}
}
|
Output:
Value 1: 89
Value 2: 50
Value 3: 10
Maximum Value: 9223372036854775807
Minimum Value: -9223372036854775808
Methods
Method |
Description |
CompareTo() |
This method is used to compare this instance to a specified object or Int64 and returns an indication of their relative values. |
Equals() |
This method is used to return a value indicating whether this instance is equal to a specified object or Int64. |
GetHashCode() |
This method is used to return the hash code for this instance. |
GetTypeCode() |
This method is used to return the TypeCode for value type Int64. |
Parse() |
This method is used to convert the string representation of a number to its 64-bit signed integer equivalent. |
ToString() |
This method is used to convert the numeric value of this instance to its equivalent string representation. |
TryParse() |
This method is used to convert the string representation of a number to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded or failed. |
Example 1:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
long value1 = 45643212342;
long value2 = 543256344233;
bool status = value1.Equals(value2);
if (status)
Console.WriteLine( "{0} is equal to {1}" ,
value1, value2);
else
Console.WriteLine( "{0} is not equal to {1}" ,
value1, value2);
}
}
|
Output:
45643212342 is not equal to 543256344233
Example 2:
using System;
class GFG {
public static void Main()
{
long val = 45789478123;
TypeCode result = val.GetTypeCode();
Console.WriteLine( "TypeCode for Int64 is: {0}" ,
result);
}
}
|
Output:
TypeCode for Int64 is: Int64
Reference:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
02 May, 2019
Like Article
Save Article