Value type vs reference types contd........
Value Type
A data type is a value type if it holds the data within its own memory allocation.
Reference Type
A reference type contains a pointer to another memory location that holds the data.
I am thankful to the author of article in http://en.csharp-online.net/Value_vs_Reference
A variable that is of type value directly contains a value. Assigning a variable of type value to another variable of type value COPIES that value.
A variable of type reference, points to a place in memory where the actual object is contained. Assigning a variable of type reference to another variable of type reference copies that reference (it tells the new object where the place in memory is), but does not make a copy of the object.
Value types are stored on the stack.
Reference types are stored on the heap.
Value types can not contain the value null. *
Reference types can contain the value null.
Value types have a default implied constructor that initializes the default value.
Reference types default to a null reference in memory.
Value types derive from System.ValueType.
Reference types derive from System.Object.
Value types cannot derive a new type from an existing value type, except for structs.
Reference types can derive a new type from an existing reference type as well as being able to implement interfaces.
Changing the value of one value type does not affect the value of another value type.
Changing the value of one reference type MAY change the value of another reference type.
The nullable type (only in .NET 2.0) can be assigned the value null.
Please refer following link for more details
http://msdn2.microsoft.com/en-us/library/t63sy5hs(VS.80).aspx
Value Types
Value types include the following:
All numeric data types
Boolean, Char, and Date
All structures, even if their members are reference types
Enumerations, since their underlying type is always SByte, Short, Integer, Long, Byte, UShort, UInteger, or ULong
Reference Types
Reference types include the following:
String
All arrays, even if their elements are value types
Class types, such as Form
Delegates
A data type is a value type if it holds the data within its own memory allocation.
Reference Type
A reference type contains a pointer to another memory location that holds the data.
I am thankful to the author of article in http://en.csharp-online.net/Value_vs_Reference
A variable that is of type value directly contains a value. Assigning a variable of type value to another variable of type value COPIES that value.
A variable of type reference, points to a place in memory where the actual object is contained. Assigning a variable of type reference to another variable of type reference copies that reference (it tells the new object where the place in memory is), but does not make a copy of the object.
Value types are stored on the stack.
Reference types are stored on the heap.
Value types can not contain the value null. *
Reference types can contain the value null.
Value types have a default implied constructor that initializes the default value.
Reference types default to a null reference in memory.
Value types derive from System.ValueType.
Reference types derive from System.Object.
Value types cannot derive a new type from an existing value type, except for structs.
Reference types can derive a new type from an existing reference type as well as being able to implement interfaces.
Changing the value of one value type does not affect the value of another value type.
Changing the value of one reference type MAY change the value of another reference type.
The nullable type (only in .NET 2.0) can be assigned the value null.
Please refer following link for more details
http://msdn2.microsoft.com/en-us/library/t63sy5hs(VS.80).aspx
Value Types
Value types include the following:
All numeric data types
Boolean, Char, and Date
All structures, even if their members are reference types
Enumerations, since their underlying type is always SByte, Short, Integer, Long, Byte, UShort, UInteger, or ULong
Reference Types
Reference types include the following:
String
All arrays, even if their elements are value types
Class types, such as Form
Delegates
Comments