C# Int16, Int32, and Int64 Types

Int keyword

The Int16, Int32 and Int64 types are aliased to keywords. Typically C# programmers prefer the C-style numeric types, which are easier to read. We demonstrate that the Int16, Int32, and Int64 types are equivalent to more commonly used types.

Int16 -> short
Int32 -> int  
Int64 -> long 

This C# article covers the Int16, Int32 and Int64 types. These types are known as short, int and long.

Example

Note

This simple program simply declares Int16, Int32, and Int64 variable instances, and then prints the Type object corresponding to them in the runtime. Then, it does the same exact thing for the short, int, and long types. The program's output shows that Int16 is equal to short, Int32 is equal to int, and Int64 is equal to long in the runtime.

Program that uses Int16, Int32, Int64 types [C#]

using System;

class Program
{
    static void Main()
    {
	{
	    Int16 a = 1;
	    Int32 b = 1;
	    Int64 c = 1;

	    Console.WriteLine(a.GetType());
	    Console.WriteLine(b.GetType());
	    Console.WriteLine(c.GetType());
	}
	{
	    short a = 1;
	    int b = 1;
	    long c = 1;

	    Console.WriteLine(a.GetType());
	    Console.WriteLine(b.GetType());
	    Console.WriteLine(c.GetType());
	}
    }
}

Output

System.Int16
System.Int32
System.Int64
System.Int16
System.Int32
System.Int64

Which should I use?

Question and answer

So should you prefer Int16 to short, Int32 to int, or Int64 to long? Not usually; conventions in most C# programs prefer the short, int, and long types. However, in some programs where the number of bytes in the types is most important, you might prefer Int16, Int32, or Int64. In methods where you use int variables, it is a poor choice to use Int32 variables instead, as int is very standard.

Summary

The C# programming language

The Int16, Int32, and Int64 types are important types in the C# language: the short, int, and long types are aliased to them. From the perspective of the runtime, your programs that specify short, int, and long are actually always using Int16, Int32, and Int64. However, for the most readable programs, the int type is usually preferred over the Int32 types.

Number Examples
.NET