0

What is the difference between the "pass-by-reference"(ref) method and "output"(out) method?

These two seems a bit confusing for me (but I've already got "pass-by-val"). :)

24th Jul 2016, 2:26 PM
Dakilang Hokage
Dakilang Hokage - avatar
2 Answers
+ 2
Hi Dakilang ref method: the parameters memory address is used/updated inside the method. out method: the parameter is transfered out of the method. I hope it helps!
24th Jul 2016, 4:31 PM
Ricardo Pucca
Ricardo Pucca - avatar
0
the ref keyword allows the parameters memory address to be sent over to the method we are calling . as we know if we send them by value another parameter is created and the parameter is copied into that parameter but the actual value of perimeter in the calling method remains same because a copy is sent to the called method. when you want to mess with the actual variable you are sending as a parameter you use ref keyword.. as you make changes in the parameter in the called program the parameter is updated with it. OUT keyword is not used to take parameters inside a method rather than this they are used to return them from a method. we declare it in the paramter list from the start that we a planning to return these variable after the method executes. it is used to return more than one parameter from the method. :)
31st Jul 2016, 2:18 AM
Javeria Khan