Monday, February 8, 2010

What is the 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)

No comments:

Post a Comment