Difference between Int64 and UInt64 in C#
Last Updated :
15 Jul, 2025
Int64: This Struct is used to represents 64-bit signed integer. The Int64 can store both types of values including negative and positive between the ranges of -9,223,372,036,854,775,808 to +9, 223,372,036,854,775,807
Example :
C#
// C# program to show the
// difference between Int64
// and UInt64
using System;
using System.Text;
public
class GFG {
// Main Method
static void Main(string[] args) {
// printing minimum & maximum values
Console.WriteLine("Minimum value of Int64: "
+ Int64.MinValue);
Console.WriteLine("Maximum value of Int64: "
+ Int64.MaxValue);
Console.WriteLine();
// Int64 array
Int64[] arr1 = {-3, 0, 1, 3, 7};
foreach (Int64 i in arr1)
{
Console.WriteLine(i);
}
}
}
Output:
Minimum value of Int64: -9223372036854775808
Maximum value of Int64: 9223372036854775807
-3
0
1
3
7
UInt64: This Struct is used to represents 64-bit unsigned integer. The UInt64 can store only positive value only which ranges from 0 to 18,446,744,073,709,551,615.
Example :
C#
// C# program to show the
// difference between Int64
// and UInt64
using System;
using System.Text;
public class GFG{
// Main Method
static void Main(string[] args)
{
//printing minimum & maximum values
Console.WriteLine("Minimum value of UInt64: "
+ UInt64.MinValue);
Console.WriteLine("Maximum value of UInt64: "
+ UInt64.MaxValue);
Console.WriteLine();
//Int64 array
UInt64[] arr1 = { 13, 0, 1, 3, 7};
foreach (UInt64 i in arr1)
{
Console.WriteLine(i);
}
}
}
Output:
Minimum value of UInt64: 0
Maximum value of UInt64: 18446744073709551615
13
0
1
3
7
Differences between Int64 and UInt64 in C#
Sr.No
| INT64
| UINT64
|
1.
| Int64 is used to represents 64-bit signed integers . | UInt64 is used to represent 64-bit unsigned integers. |
2.
| Int64 stands for signed integer. | UInt64 stands for unsigned integer. |
3.
| It can store negative and positive integers. | It can store only positive integers. |
4.
| It takes 8-bytes space in the memory. | It also takes 8-bytes space in the memory. |
5.
| The range of Int64 is from -9223372036854775808 to +9223372036854775807. | The UInt64 ranges from 0 to 18446744073709551615. |
6.
|
Syntax to declare the Int64 :
Int64 variable_name;
|
Syntax to declare the UInt64:
UInt64 variable_name;
|