0
What is a data type?
1 Answer
+ 1
A data type is needed to allow us to store a value inside a variable, i.e.:
int x = 0;
'int' in the above example is the data type, other examples are, bool, double, char, etc.
There are two types of data type; a 'value type', or 'reference type', the list above are all value types. A value type uses a different area of memory than a reference type (called the 'stack' and the 'heap' respectively). The 'stack' memory is discarded more quickly than that of the 'heap'. Examples of reference types are, string, object & arrays.
With a value type, once the method that contains that data type has finished executing, the memory is discarded from the 'stack'. A reference type on the other hand, is not discarded when the method has finished executing, it is discarded when the program thinks it's no longer needed.
I haven't gone into all the details, and I would recommend reading up on value and reference types on MSDN for a full breakdown.
Hope this helped, though!