VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-int-64-struct/

⇱ C# Int 64 Struct - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# Int 64 Struct

Last Updated : 11 Jul, 2025

In C#, the Int64 struct represents a 64-bit signed integer and is commonly used as the long data type. It belongs to the System namespace and provides various methods to perform operations like mathematical computations, parsing, and type conversion. The Int64 struct inherits from ValueType, which in turn inherits from Object.

  • Range: Int64 ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
  • Bitwise Operations: It supports bitwise operations like AND (&), OR (|), XOR (^), NOT (~), and shifts (<<, >>).
  • Convert and Math Class Compatibility: It works with methods from Convert and Math classes for operations like rounding, absolute value, and power calculations.

Fields

FieldsDescription
MaxValueThis field is used to represent the largest possible value of an Int64. This field is constant.
MinValueThis field is used to represent the smallest possible value of an Int64. This field is constant.

Example: Using MaxValue and MinValue Fields


Output
Value 1: 89
Value 2: 50
Value 3: 10
Maximum Value: 9223372036854775807
Minimum Value: -9223372036854775808

Methods

MethodDescription
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 Equals() Method


Output
45643212342 is not equal to 543256344233

Example 2: Using GetTypeCode() Method


Output
TypeCode for Int64 is: Int64

Bitwise Operations with Int64

Example:


Output
Bitwise AND (a & b): 1
Bitwise OR (a | b): 7
Bitwise XOR (a ^ b): 6
Bitwise NOT (~a): -6
Comment
Article Tags:

Explore