+ 2

Whats the diffrenet between passing the variables by out and ref in c# ?

question

12th Aug 2017, 1:45 PM
Mohamed Abdalkader
Mohamed Abdalkader - avatar
3 Answers
+ 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
12th Aug 2017, 2:19 PM
Ipang
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.
13th Aug 2017, 7:29 AM
Aprajits