Tuesday, May 28, 2013

Reference Type

Reference Type objects are those which have a do not have a separate memory segment instead they have a pointer connecting the variable and the actual object, when a reference type variable is copied to another reference type variable, both the variables share the same memory segment and changes done to one of the variable will affect the value of the other, since there is only one underlying object and 2 pointer pointing to the same object.

All Reference Type objects are implicitly derived from System.Object

By default all parameters passed to a function are of Value Type, we can force the parameters to be passed by reference by adding a ref keyword in front of the parameter.

All Reference Type variables are stored in the heap, unlike stack memory management heap memory management is not straight forward, it required memory management and garbage collection logic to handle the memory of the objects.

Classes are Reference Types.

Search Flipkart Products:
Flipkart.com

No comments: