Monday, May 21, 2007

Out Parameter

What is an out parameter? What is the difference between ref and out parameters?
In addition to passing values by reference, you can also specify that a given parameter is an out parameter by using the out keyword, which is used in the same way as the ref keyword (as a modifier to the parameter in the function definition and in the function call.

What are the differences between ref and out parameters?
· It is illegal to use an unassigned variable as a ref parameter; you can use an unassigned variable as an out parameter.
· Out parameter must be treated as an unassigned value by the function that uses it. This means that it is OK to use the assigned variable as an out parameter, the value stored in this variable will be lost when the function executes.

No comments: