C# int keyword: Here, we will find out about the int keyword in C#, what is int keyword, how to utilize it in C#?
C# int keyword:
In C#, int is a keyword which is utilized to proclaim a variable that can store a vital sort of significant worth (marked whole number) the scope of – 2,147,483,648 to 2,147,483,647. int keyword is an assumed name of System.Int32.
It involves 4 bytes (32 bits) space in the memory.
Syntax:
int variable_name = value;
C# code to show an example of int keyword:
Here, we are pronouncing an int variable num, introducing it with the worth 12345 and printing its worth, type, and size of an int type variable.
using System;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
//variable declaration
int num = 12345;
//printing value
Console.WriteLine("num: " + num);
//printing type of variable
Console.WriteLine("Type of num: " + num.GetType());
//printing size
Console.WriteLine("Size of a int variable: " + sizeof(int));
//printing 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:
num: 12345
Type of num: System.Int32
Size of a int variable: 4
Min value of int: -2147483648
Max value of int: 2147483647