What is a data type?

Experience Level: Junior
Tags: C#

Answer

Data type in programming describes what value the variable can hold. Different values can have different data types.

Let's take an Age of a person as an example.

If we are talking about age, we could maybe agree the age could be numeric value. So it will be a number. But will it be an integer or decimal number? Will the Age be defined in number of years or number of months or maybe minutes or seconds? Someone doesn't care whether a persion is 30 or 31 years old. But what if you want to be more precise? What if you want to measuere how many days are remaining to person's next birthday? In such situation knowing that person is 30 years old would be different than knowing that persion is 30.2 years old, right?

Related C# job interview questions
C# for beginners
C# for beginners

Are you learning C#? Try our test we designed to help you progress faster.

Test yourself