int Keyword in C#

Last Updated : 15 Jul, 2025
Keywords are the words in a language that are used for some internal process or represent some predefined actions. int is a keyword that is used to declare a variable which can store an integral type of value (signed integer) the range from -2,147,483,648 to 2,147,483,647. It is an alias of System.Int32. Syntax:
int variable_name = value;
Int keyword occupies 4 bytes (32 bits) space in the memory. Example:
Input: num: -245

Output: num: -245
        Size of an int variable: 4

Input: num = 7923645

Output: Type of num: System.Int32
        num: 7923645
        Size of a int variable: 4
Example 1: csharp
// C# program for int keyword
using System;
using System.Text;

class geeks {

    static void Main(string[] args)
    {
        // variable declaration
        int num = -245;

        // to print value
        Console.WriteLine("num: " + num);

        // to print size
        Console.WriteLine("Size of a int variable: " + sizeof(int));
    }
}
Output:
num: -245
Size of a int variable: 4
Example 2: csharp
// C# program for int keyword
using System;
using System.Text;

namespace Test {

class geeks {

    static void Main(string[] args)
    {
        // variable declaration
        int num = 7923645;

        // to print type of variable
        Console.WriteLine("Type of num: " + num.GetType());

        // to print value
        Console.WriteLine("num: " + num);

        // to print size
        Console.WriteLine("Size of a int variable: " + sizeof(int));

        // to print minimum & maximum value of int
        Console.WriteLine("Min value of int: " + int.MinValue);
        Console.WriteLine("Max value of int: " + int.MaxValue);

        // hit ENTER to exit
        Console.ReadLine();
    }
}
}
Output:
Type of num: System.Int32
num: 7923645
Size of a int variable: 4
Min value of int: -2147483648
Max value of int: 2147483647
Example 3: csharp
// C# program for int keyword
using System;
using System.Text;

class geeks {

    static void Main(string[] args)
    {

        // variable declaration
        int num1 = 2147483650;

        // to print value
        Console.WriteLine("num1: " + num1);

        // variable declaration
        int num = 792.53;

        // to print value
        Console.WriteLine("num: " + num);
    }
}
Error: When we input wrong integer and also input number beyond the range
Constant value `2147483650' cannot be converted to a `int' Cannot implicitly convert type `double' to `int'
Comment
Article Tags:

Explore