0
What is different between ref and out when I declared argument in method? ?
I need clear answer
1 Respuesta
+ 2
*)if you enter the parameter without ref or out then we are dealing with a 'local variable' for the method that have the same value of the variable intered as parameter but in different variable that ends when the method ends
*) ref means that you give the reference of the variable to the method then the method will not create a local variable , it will work using the variable itself .. that means that the method knows the value of the variable before executing it and it it can change it during executing
*)out also means that the method has the variable itsel but the difference here is that it does not have the variable value before being executed ( it will initialize the variable and give it a value but will not take an initiale value from outside the method)
___________________________________________
out is used when you need more than one return in your method ,when ref is used when you want to change the value of a variable.
hope this help :)