Value types and Reference types
Here are the key points:
■ The value of a reference type expression (a variable for example) is a reference,
not an object.
■ References are like URLs—they are small pieces of data that let you access the
real information.
■ The value of a value type expression is the actual data.
■ There are times when value types are more efficient than reference types, and
vice versa.
■ Reference type objects are always on the heap, but value type values can be on
either the stack or the heap, depending on context.
■ When a reference type is used as a method parameter, by default the parameter
is passed by value—but the value itself is a reference.
■ Value type values are boxed when reference type behavior is needed; unboxing
is the reverse process.
Post By : Dipen Shah
Blog By : Dipen Shah
Here are the key points:
■ The value of a reference type expression (a variable for example) is a reference,
not an object.
■ References are like URLs—they are small pieces of data that let you access the
real information.
■ The value of a value type expression is the actual data.
■ There are times when value types are more efficient than reference types, and
vice versa.
■ Reference type objects are always on the heap, but value type values can be on
either the stack or the heap, depending on context.
■ When a reference type is used as a method parameter, by default the parameter
is passed by value—but the value itself is a reference.
■ Value type values are boxed when reference type behavior is needed; unboxing
is the reverse process.
Post By : Dipen Shah
Blog By : Dipen Shah