Difference between value types and reference types?

Value types are inherited from system.valuetypes
Reference types are inherited system.object.

Value types are stored in a stack
Reference types are stored on heap

When variables are passed by values as parameters, then no change can be made to them when retrieved.
When variables are passed by reference, their address is passed due to which a change in their values can be reflected back in the calling function.

In .NET, when you pass a variable by value, the syntax would be: (ByVal a as datatype)
and when passed by reference (ByRef a as datatype)

Related Article:






Tags:
Hot on Web:


About author