Value type Stored in StackReference type stored in Heap , Destroyed by Garbage Collection
The value types are the types which can be fixed in size i.e. int, float, double, short, etc. And the reference types are the types which can be variable length size i.e. string and object. the value types have default values as 0 and the reference types have default values as NULL. the Value types are converted to reference types, is known as boxing. e.g. int i = 100;object obj = i; // boxing And the value types i.e. converted into reference types are again converted back into the value type is known as un-boxing. This conversion is done by an explicit conversion as:- e.g. int j = Convert.ToInt(i); //Un-boxing
value type will not get destroyed by garbage collector where as reference type get destroyed by garbage collector.
go to http://msdn.microsoft.com/en-us/library/4d43ts61(v=vs.90).aspx
Data types are classified into 2 categories First one is Value types and other one is Reference typesI) Value types: Value types stored the data on STACK(First In Last Out) which is a place where data stores in fixed length such as int, float, char etc...Note:STACK is under control of Operating System which doesn't provide automatic memory management but it is faster in access.II) Reference types: Reference types are stored on HEAP memory which is another place where data can be stored. C# supports two predefined reference types i) Object, ii)String Note: HEAP is more managed and more over it will be under the control of "Garbage Collector"