| VALUE TYPE | |
| - |
Value type derives from System.ValueType which derives from System.Object
|
| - | Value types directly contains their values |
| - |
When you copy from one value type variable to another it copies all the data. So if you change one variable it does not affect another variable.
|
| - | Value Type are stored in Stack. |
| - |
Value type has default value. For eg: int i; So i has default value of 0.
|
| - |
Runtime can create, delete, remove the value type quickly. So no garbage collection needed.
|
| - |
It does not contain null values unless you can make it as nullable type.
|
| - | There are three categories in value type |
| 1 | Built-in Type |
- Integral type (sbyte, byte, char, short, ushort, int, uint, long, ulong)
| |
| - Floating point type (float, double) | |
| - Decimal type (decimal) | |
| 2 | Bool |
| 3 | Struct,Enum |
| REFERENCE TYPE | |
| - |
Reference Type is derive from System.Object
|
| - |
Reference Type variable stores address of their data.
|
| - |
It has the pointer to points to the data.
|
| - |
When you copy from one reference type variable to another it copies only the reference. So if you change one variable it will affect another.
|
| - |
Reference types are stored in the Heap.
|
| - |
Reference types always has null values.
|
| - |
The memory used by the reference type will handled by Garbage Collection.
|
| - |
Class, Interface, Object, String, Arrays, Stream, Exception, Delegate, StringBuilder are the reference type.
|
Wednesday, October 3, 2012
Value Type Vs Reference Type
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment