Difference between Ref vs. Out

Category:

The Ref and Out Parameters are quiet similar, both parameters are used to return back some value to the caller of the function. But there is a main difference between this two is when we use the out parameter, the program calling the function need not assign a value to the out parameter before making the call to the function. The same is not true for the reference (ref) type parameter. For a ref type parameter, the value to the parameter has to be assigned before calling the function. If we do not assign the value before calling the function we will get a compiler error.

Comments (0)

Post a Comment