Advertisement
Beginner C# Programming, Data Types in C#

Difference between int and Int32 in C#

Short answer

int is simply a C# keyword alias for the System.Int32 struct provided by the Base Class Library, meaning both represent exactly the same 32 bit signed integer type and can be used completely interchangeably.

Save C# Programming mock interview
Advertisement
AModel answer
int is simply a C# keyword alias for the System.Int32 struct provided by the Base Class Library, meaning both represent exactly the same 32 bit signed integer type and can be used completely interchangeably. There is no difference in behavior or performance between them, and the choice between using int or Int32 is purely a matter of coding style and readability preference.
int number1 = 100;
System.Int32 number2 = 100;
// Both lines create the exact same type of value
Real-world example
A coding standards document at a company simply recommends using the lowercase int keyword everywhere instead of Int32, purely for consistency with common C# conventions, since both compile down to the identical underlying type.
Likely follow-ups
  • Are there similarly aliased types for other numeric types like long or short?
  • Does using int versus Int32 ever matter when working with generics or reflection?
Related topics