In C# every variable is associated with a data type. Data types specify the size and type of the values that can be stored.
The types in C# are divided into two types
1. Value types
2. Reference types
Both value types and reference types are differ in characteristic
Difference between value types and reference types
Value type are stored on the stack and when a value of a variable is assigned to another variable, the value is actually copied i.e. two identical copies of the value are available in memory
Normally the value types are grouped in two categories...
User Defined types:
· Real Number
N=m; Here the value are actually copied.
Reference type are stored on the heap and when a value of a variable is assigned to another variable, only the reference is copied, actual value remains in the same memory location i.e. two reference to a single value
Reference types also divided into two groups
· User Defined types
· Predefined types
User defined types:
· Object type
· String type
N=m; Here only the reference has been copied, the value are stored same location,any changes on m also affect the changes on n.
If you like this article share this information with your friends
Post your comments here..