Integer Type Variable in C#.Net

Number Variable in C#.Net

Previous post we learnt what is variable and how to declare and initialize variable with value. Now in this post we will learn Integer Number type variable.

We all know c# supports basic data types like : int, float, char, string and bool.

Here we learn about Integer type variable in c#. The integer variable supports data types such as int, uint, long, ulong, byte, sbyte.

For store number in a memory and manipulate it we need Integer variable. An integer include whole numbers without decimal point. means 5 of 5.4 and 6 of 5.7.

We use int datatype for declare integer variable. Integer variable is a things which store the number and allow programmer to manipulate the value later in program.

Let’s understand Integer type of variable.

Integer type variable supports data types : int, uint, long, ulong, byte, sbyte
Integer variable declare with datatype int in

32 bit integer type variable categorize in two type.

  • Int32 – Signed integer
  • Uint32 – Unsigned integer

The 32 bit signed integer range from -2,147,483,648 to 2,147,483,647.
The 32 bit unsigned integer range from 0 to 4294967295.

C# integer variable declaration

<data_type> <Variable_name>


int myno;
here int = datatype and myno = variable name

here we assign value 10 to myno variable.

Let’s an example in c# .net to understand integer type variable in visual studio .Net.

Open Visual Studio –> New Website –> Add New Web form in Solution Explorer.

go to .cs page declare variable with int data types show like below screen.

Integer type variable in
Integer type variable in

Here, we declare myno variable with int data type. We just declare myno variable but we have not initialize myno variable so the c# compiler shows warning message like The variable ‘myno’ is declared but never used.

Initialize variable after declaration

Integer type variable in
Integer type variable in

Here, first we declare variable myno with int data type and then initialize myno variable with value 10, but still it not used in our program so the c# compiler shows warning message like: The variable ‘myno’ is assigned but its value is never used.

Integer type variable in
Integer type variable in

Here, we declare variable and then assign value to variable myo=10. After assign value we use myno variable for display output on web form using response.write(myno).

Next C# post we will learn about string type variable and use arithmetic operation with number and string variable.

(Visited 88 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha *