Before examining the data types in C#, it is important to understand that C# distinguishes between two categories of data type:
1. Value types
2. Reference types
Conceptually, the difference is that a value type stores its value directly, whereas a reference type stores a reference to the value.
Value types in C# are basically the same as simple types (integer, float, but not pointers or references) in Visual Basic or C++.
Reference types are the same as reference types in Visual Basic and are similar to types accessed through pointers in C++.
These types are stored in different places in memory; value types are stored in an area known as the stack , and reference types are stored in an area known as the managed heap . It is important to be aware of whether a type is a value type or a reference type because of the different effect each assignment has.
For example, int is a value type, which means that the following statement will result in two locations in memory storing the value 20:
// i and j are both of type int

Join the conversation! Your thoughts help the community grow.