+ 2
Whats the diffrenet between passing the variables by out and ref in c# ?
question
3 Antworten
+ 4
Quoted from Microsoft C# reference:
"An argument that is passed to a ref parameter must be initialized before it is passed. This differs from out parameters, whose arguments do not have to be explicitly initialized before they are passed."
Source:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref
0
Ref keyword used when call by reference. Any changes made to the parameter in method will be reflectedin the variable when control passes back to calling method.
Out keyword used when we have to take input from method.