When you work with any programming language, you will hear the phrase "Data type". So what is the data type? And is it important? How to use it? And in C# language, what data types are there? Those are definitely the questions that anyone new to programming asks.
When you declare a variable, make sure you declare a data type to store the data in an area of RAM. Based on the data type that you declare, the system will allocate a memory area and decide what information and domain values can be stored in that memory area.
(Pic 1: Illustrate data type –
source: Internet)
In C# there are the following data types: Value type (Value type), reference type (Reference type), and pointer type (Pointer type). In this article, I only show the Value type.
Value Type is inherited from the System.ValueType class, which stores a value of a type that directly transforms the value.
(Pic 2: Illustrate Value Type.)
When knowing the data types, programmers will easily use them to declare variables in a reasonable way to avoid wasting memory resources, as well as avoid errors in the process of using variables.
For example, We need 1 variable to store a person's age, you just need to declare the byte type is enough. Because the value range of byte type is 0 – 255.
In short, understanding and knowing how to use data types is important in programming. It is the most basic. If you compare programming as an elaborate discipline, then understanding the data types in a programming language, and mastering it is like doing basic exercises. Without it, you can hardly reach a higher realm in programming.
Related Post:




