«^»
6.1. value, ref and out parameters

In Java, all parameters are value parameters. A value parameter acts like a local variable of the method whose initial value is the value of the argument used in the call.

C# also has ref parameters and out parameters. If a method has a ref/out parameter, then that parameter represents the same variable as the variable given as the argument.

Here is an example of a ref parameter:

private static void iIncrease(ref int pCount)
{
    pCount++;
}
public static void Main() 
{
    int tCount = 1;
    iIncrease(ref tCount);
    Console.WriteLine(tCount);
    // 2 would be output
}

Note that the keyword ref appears both in the parameter list and in the argument list.

An out parameter is used in a similar way to a ref parameter. The differences between a ref parameter and an out parameter are: