Using ref and out Parameter
When we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect the actual variable.Even the variable passed as out parameter is similar to ref, but there are few implementation differences when you use it in C# .
Argument passed as ref must be initialized before it is passed to the method, where as in case of out its is not necessary,but after a call to the method as an out parameter the variable must be initialized.
When to use ref and out parameter. out parameter can be used when we want to return more than one value from a method.
IMPORTANT NOTE : We now know what are ref and out parameters, but these are only for C#(these are only understood by csc Compiler) when looking inside the IL Code there is no difference whether you use ref or out parameters. The implementation of ref and out parameter in IL Code is same.
When Calling a method and in the method signature after the datatype of the parameter a & sign is used, indicating the address of the variable.
Source Code: RefOut.cs
Save the Above File as RefOut.Cs , Compile C:\>csc RefOut.cs and Run C:\>RefOut
To know more about Out parameter, follow below articles