Difference between Int16, Int32 and Int64 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#

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
  }
}

chevron_right


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#

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
  }
}

chevron_right


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#

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
  }
}

chevron_right


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;



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.