Difference between Int16, Int32 and Int64 in C# - GeeksforGeeks

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;  publicclass 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;  publicclass 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 usageusing 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.
2.
3.
4.
5.
 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;

CSharp-Int16-Struct
CSharp-Int32-Struct
CSharp-Int64-Struct
C#
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# | Method Overriding
C# | Class and Object
C# | Constructors
Extension Method in C#
Introduction to .NET Framework
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between Process and Thread
Stack vs Heap Memory Allocation