+ 3
(ref) VS (out)
i want to ask what the defferances between passing variables to functions by out word and ref word? THANK YOU!
8 Answers
+ 4
@ Ollie Q I do not agree with you, on the ref part.
by val : doesnât change the value for the rest of the program
But the ref keyword is especially used for changing the value for the rest of the program.
Have a look at this example code.
https://code.sololearn.com/c0mzKfHb0nuM
+ 7
out parameter can be uninitialized
ref must get initialized
+ 6
sneeze your answers better than mine and also more acurate ans also nice program.
p.s thanks for helping me with the NuGet library last week
+ 3
Hi Star PRO X
the out keyword changes the value of the varible in the function and outputs the varible in the program.
the ref keyword acepts a varible into the function but doesnât change the value for the rest of the program
i hope this helps
+ 1
i see that out in your example that out and ref working same... they changed the value of given variable on calling that's all....
+ 1
Ollie Q keep coding, keep learning.
0
Star PRO X Notice that the out parameter cannot be initialized!! This is a huge difference between and ref and out.
0
Thank you guys i understand them đđ