Error can be resolved by assigning a value to the integer variable before invoking the Process() method. So now we got to know the syntactical difference between the out and ref keywords.

When out parameter is declared in the method declaration, the method body should assign a value to the out variable before returning. So its the responsibility of the callee to assign the value to the out parameter before it returns.

Whereas when ref parameter is declared in the method, the argument being passed while invoking the method should have got the value assigned. So its the responsibility of the caller to assign the value for the ref argument before calling the method.

Example for the out keyword in .NET framework:

publicstaticbool TryParse(string s,out DateTime result)

Example of the ref keyword in .NET framework:

publicstaticdouble Exchange(refdouble variable1, double value)

Summary:

Use the out parameter for value types, if callee method should assign a value to a parameter before returning.

Use the ref parameter for value types, when caller has already assigned value to a parameter even before invoking the method. The method body can modify the ref argument value, but there is no restriction as such.