Synopsis
- Introduction.
- Definition of data type.
- Need of variable.
- Use of data type.
- Advantages of data type.
- Conclusion.
Introduction
Memory is a primary use in programs, without memory programs can't do anything. Memory is a storage space or platform of a process of a program or software. This article explains how to allocate memory, how to save memory and how to set a name for memory. Handle the memory with care because memory is not a simple thing, it is very expensive.
Definition of data type
A data type is a type of data that specifies to the compiler the type of data store in the allocated memory.
Need of variable
First create the memory then store data into the memory. If you do not create it then we cannot store data into it. If we create memory the we should assign a name for the memory. We cannot access memory physically, only logically, if it is accessed logically then we only nee to use the memory's name or its address.
A variable is the name of a memory name. There are many rules available to create a variable name.
- Variable name should be meaningful.
- Not allowed blank space in variable name.
- First character should be a letter or underscore.
- Variable name should not be reserved words.
- The maximum variable length is 511 characters.
The following explains how to declare a variable and how to allocate memory.
Example
Memory Allocation
Figure 1: Memory Allocation
The way to allocate memory is shown in Figure 1. "First" is a variable name. "1001" is a memory address. The system generates a memory address automatically. Memory increases based on the data type byte. For example an integer has 2 bytes so the memory address increaseas by two. For example a memory address of 1001 and next memory address is 1003. It is based on data type.
Example
Figure 2: Data stores in its memory
Figure 3: Data stores
Here declare two variables "’First, Second” and assign values. Figure 2 shows how the data is stored in memory the same as in Figure 3.
Use of data type
The data type defines the size of the memory. Store the data into memory and choose the relevant data type based on which data wil be stored. Memory is very expensive so do not waste memory. If we are going to store an integer data type then do not declare it as double because if the allocated memory is for one variable then we cannot use another variable so memory will be wasted. 
Figure 4: Memory status
In Figure 4 the Red color represents used memory and the Green color represents unused memory.
Unused memory cannot be used anywhere, it can store only a specific capacity using the same variable. In "varFirst" only an integer is store that must not be declared a double because that specific memory takes more memory. If memory is allocated then we cannot use it so it is a waste of memory.
Advantages of data type
- Data type defines the size of a variable in memory.
- Data type saves memory from unused memory.
- It is used to store various types of data using data type.
- Can create a user-defined data type using standard data type.
Conclusion
Data types are at the heart of programs in C#, not only C#, but in every program. Handle the memory using a data type. Data type and variable both are very important. Programmers use the correct data type in the correct place.


Pravas RanjanPosted Oct 31, 2018, 1:58 AM EDT
Good Article Vignesh Sir
Manav PandyaPosted Sep 30, 2016, 6:14 AM EDT
Great post sir ...
Shobana JPosted Jul 12, 2016, 10:56 PM EDT
Easy to understand..thanks for sharing
SubashPosted Jul 3, 2016, 9:01 PM EDT
Good Explanation
Sonu ChaudharyPosted Mar 18, 2016, 11:14 AM EDT
nice one
Asfend YarPosted Feb 29, 2016, 12:56 AM EST
good
Mahsa HassankashiPosted Jul 10, 2015, 1:40 PM EDT
Nice description keep on Dear Vignesh Mani
Gareth BradleyPosted Jul 10, 2015, 3:26 AM EDT
Another brilliant article. Maybe a follow up article on the difference between Value and Reference Types?
periyanayagam sivarajPosted Jul 8, 2015, 9:40 AM EDT
Nice Article, Easy understanding and very useful.
Santhakumar MunuswamyPosted Jul 3, 2015, 11:01 AM EDT
Thanks for nice article.:)
Vignesh ManiTOP 100Posted Jul 2, 2015, 12:00 AM EDT
Thank You To All
Jason FPosted Jul 1, 2015, 11:56 PM EDT
Excellent article, well explained.
Favas CMPosted Jul 1, 2015, 8:42 PM EDT
good article easy to understand
Pooja BaraskarPosted Jul 1, 2015, 10:02 AM EDT
Very well explained.
Sibeesh VenuTOP 100Posted Jul 1, 2015, 2:38 AM EDT
Good one.
Pankaj Kumar ChoudharyTOP 100Posted Jul 1, 2015, 1:48 AM EDT
Nice One Sir........
Mohan ArPosted Jun 30, 2015, 11:47 PM EDT
Good one.
Hari Krishnan VelayuthamPosted Jun 30, 2015, 10:33 PM EDT
Nice ...
Vignesh ManiTOP 100Posted Jun 30, 2015, 9:36 PM EDT
Thank You
Gopi ChandPosted Jun 30, 2015, 9:04 PM EDT
Nice one