Tuesday, March 27, 2012

Where is pass by reference is useful?

1.
Suppose you have large object to pass to a function, better to pass by reference instead of passing bye value or the object itself.

2.
Least Memory Management.

3.
No 0 values possible -> Called function will know that the object have been created and you are passing address of that object.

4.
New variable are not created, rather already created objects or variable are used.

5.
We can return multiple values from a function.

6.
It allows us to have the function change the value of the argument, which is sometimes useful.

7.


more practical reason will come soon ......

Thursday, March 1, 2012

Difference between ref and out parameters in .NET


The out and the ref parameters are used to return values in the same variables, that you pass an an argument of a function. These both parameters are very useful when your function needs to return more than one values.


                The out Parameter
The out parameter can be used to return the values in the same variable passed as a parameter of the function. Any changes made to the parameter will be reflected in the variable.

Live

Your Ad Here