You are looking for a clear understanding of the data types in C#? Then you are exactly right here. This tutorial gives you the opportunity to learn the basics about the integer data type and put your knowledge into practice through simple examples. We will create a console application step by step in which we will work with the integer data type.
Key insights
- The integer data type is a 32-bit data type with a value range of -2,147,483,648 to 2,147,483,647.
- You can declare, initialize, and work with variables.
- Using basic arithmetic operations, you can perform effective calculations with integers in C#.
Step-by-Step Guide
Let's start developing a simple console application in Visual Studio to understand the integer data type.
First, open Visual Studio and create a new project. Choose a console application and name it "ExampleDataType". The project name will help you identify the specific project later.

In the next step, you will make a variable declaration. Just like we learned in the video, you need the keyword int, followed by a name you choose for the variable. In our example, we will use the name "zahl1". Don’t forget to end the line with a semicolon to correctly complete the declaration.

Now that the variables are declared, the next step is variable initialization and value assignment. Simply write "zahl1 = 33;" to assign a value to the variable. This shows that "zahl1" stores the integer 33.
A common approach in programming is to do the declaration and initialization at the same time. This means you combine the previous steps into a single statement. For example, you could write it like this: int zahl2 = 45;. Here, the variable "zahl2" is also declared and immediately assigned the value 45.
Note that in Visual Studio, the variable "zahl1" will have a wavy line under its name, indicating that its value is not yet used. Click on it to get more information about it.
To use these variables, simply sum them up. Create a new variable named "totalSum" and assign it the value of "zahl1 + zahl2". Your line for this could look like: int gesamtSumme = zahl1 + zahl2;.
Now that we have calculated the total sum, we of course want to see the result. Use Console.WriteLine to output the value. You could write something like: Console.WriteLine("Total Sum = " + totalSum); so that the user receives the output as a clear message.
Don’t forget to end the program with Console.ReadKey(); to keep the console window open so you can see the result before it closes.
If you now run your program and see that the total sum is 78, congratulations! You have successfully worked with integer data types in C#.

In the next video, we will deal with floating-point numbers, but until then, you have practiced the basics with integer numbers.
Summary – C# Programming: Basics of the Integer Data Type
In this guide, you have learned the essentials of working with the integer data type in C#. You have created a simple console application, declared variables, initialized them, and performed arithmetic operations. With this knowledge, you are ready to explore more complex data types and operations in your future projects.
Frequently Asked Questions
What is an integer data type in C#?An integer data type in C# is a 32-bit data type that stores whole numbers.
What is the value range of an integer data type?The value range of an integer data type is between -2,147,483,648 and 2,147,483,647.
How do I declare a variable in C#?To declare a variable, write the keyword for the data type, followed by a name and a semicolon.
How can I perform variable initialization in C#?Variable initialization is done by assigning a value with the equal sign, for example: int zahl = 10;.
Why does my variable show a wavy line under its name?The wavy line indicates that the variable has been declared but not further used.