Sunday, November 27, 2011

Difference between value type and reference type data types in c#

Title: What is difference between Value and Reference type in C#.net

Description:While using  the c#.net we have to know some basic concepts such as data types.Now i would like to describe the features and difference of data types
Value Type:
1.Value type holds the data directly
2.value type doesn't contain default value
3.Value type should be in STACK memory at compile time
4.STACK is not accessible with Garbage collection(GC)
5.Example for value types:Structures,Enums etc
Reference Type:
1.Reference type holds the address but not data
2.Reference type holds the default value
3.Reference type will be stored in HEAP memory at run time
4.HEAP memory is accessible with GC
5.Example for Reference type:Classes,objects,arrays.Interfaces etc
Post a Comment

Bel