Difference between Int16, Int32 and Int64 in C#
Last Updated :
26 May, 2020
Int16: This Struct is used to represents 16-bit signed integer. The Int16 can store both types of values including negative and positive between the ranges of -32768 to +32767.
Example :
C#
// C# program to show the
// Int16 Struct usage
using System;
using System.Text;
public
class GFG {
// Main Method
static void Main(string[] args) {
// printing minimum & maximum values
Console.WriteLine("Minimum value of Int16: "
+ Int16.MinValue);
Console.WriteLine("Maximum value of Int16: "
+ Int16.MaxValue);
Console.WriteLine();
// Int16 array
Int16[] arr1 = {-3, 0, 1, 3, 7};
foreach (Int16 i in arr1)
{
Console.WriteLine(i);
}
}
}
Output:
Minimum value of Int16: -32768
Maximum value of Int16: 32767
-3
0
1
3
7
Int32: This Struct is used to represents 32-bit signed integer. The Int32 can store both types of values including negative and positive between the ranges of -2147483648 to +2147483647.
Example :
C#
// C# program to show the
// Int32 struct usage
using System;
using System.Text;
public
class GFG {
// Main Method
static void Main(string[] args) {
// printing minimum & maximum values
Console.WriteLine("Minimum value of Int32: "
+ Int32.MinValue);
Console.WriteLine("Maximum value of Int32: "
+ Int32.MaxValue);
Console.WriteLine();
// Int32 array
Int32[] arr1 = {-3, 0, 1, 3, 7};
foreach (Int32 i in arr1)
{
Console.WriteLine(i);
}
}
}
Output:
Minimum value of Int32: -2147483648
Maximum value of Int32: 2147483647
-3
0
1
3
7
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
// Int64 struct usage
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
Difference between Int16, Int32 and Int64 in C#
Sr.No
| INT16
| INT32
| INT64
|
1.
| Int16 is used to represents 16-bit signed integers. | Int32 is used to represents 32-bit signed integers . | Int64 is used to represents 64-bit signed integers. |
2.
| Int16 stands for signed integer. | Int32 also stands for signed integer. | Int64 also stands for signed integer. |
3.
| It can store negative and positive integers. | It can also store negative and positive integers. | It can also store negative and positive integers. |
4.
| It takes 2-bytes space in the memory. | It takes 4-bytes space in the memory. | It takes 8-bytes space in the memory. |
5.
| The range of Int16 is from -32768 to +32767. | The range of Int32 is from -2147483648 to +2147483647. | The range of Int64 is from -9223372036854775808 to +9223372036854775807. |
6.
|
Syntax to declare the Int16 :
Int16 variable_name;
|
Syntax to declare the Int32 :
Int32 variable_name;
|
Syntax to declare the Int64 :
Int64 variable_name;
|
Similar Reads
Difference between UInt16, UInt32 and UInt64 in C# UInt16: This Struct is used to represents 16-bit unsigned integer. The UInt16 can store only positive value only which ranges from 0 to 65535. Example : C# // C# program to show the // UInt16 struct using System; using System.Text; public class GFG{ // Main Method static void Main(string[] args) { /
3 min read
Difference between Int16 and UInt16 in C# Int16: This Struct is used to represents 16-bit signed integer. The Int16 can store both types of values including negative and positive between the ranges of -32768 to +32767. Example : C# // C# program to show the // difference between Int16 // and UInt16 using System; using System.Text; public cl
2 min read
Difference between Int64 and UInt64 in C# 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 us
2 min read
Difference between Int32 and UInt32 in C# Int32: This Struct is used to represents 32-bit signed integer. The Int32 can store both types of values including negative and positive between the ranges of -2147483648 to +2147483647. Example : C# // C# program to show the // difference between Int32 // and UInt32 using System; using System.Text;
2 min read
Difference between byte and sbyte in C# In C#, a single byte is used to store 8-bits value. The byte and sbyte both are used for byte type of data. byte : This Struct is used to represent 8-bit unsigned integers. The byte is an immutable value type and the range of Byte is from 0 to 255. Example : C# // C# program to demonstrate // the by
2 min read