Skip to main content
The int keyword in C# is a built-in integral numeric type that represents a 32-bit signed integer. It is a language alias for the .NET System.Int32 struct. As a value type, an int is stored directly in memory where it is declared (typically the thread stack, or inline within a reference type on the managed heap), rather than being allocated as a separate object.

Technical Specifications

  • Underlying .NET Type: System.Int32
  • Memory Size: 32 bits (4 bytes)
  • Binary Representation: Two’s complement
  • Minimum Value: -2,147,483,648 (int.MinValue)
  • Maximum Value: 2,147,483,647 (int.MaxValue)
  • Default Value: 0

Syntax and Literals

The int type supports decimal, hexadecimal, and binary literals. Digit separators (_) can be used to improve readability. No type suffix is required for an int literal, as C# defaults to int for whole numbers within the 32-bit range.

Type Conversions

Conversions between int and other numeric types are governed by the potential for data loss. Implicit Conversions C# allows implicit conversions from int to types that have a larger memory footprint or can accommodate the entire 32-bit signed range without truncation.
Explicit Conversions Converting to an int from a larger integral type or a floating-point type requires an explicit cast. Floating-point conversions truncate the fractional component toward zero.

Overflow Behavior

By default, arithmetic operations on int in C# execute in an unchecked context. If an operation exceeds int.MaxValue or falls below int.MinValue, it silently wraps around using two’s complement arithmetic. This behavior can be modified using the checked keyword or compiler flags, which will instead throw an OverflowException.
Tired of Poor C# Skills? Fix That With Deep Grasping!Learn More