This documentation is archived and is not being maintained.

Reference Operator (&)

The & operator is used to pass references to variables to methods with reference or out parameters. Changes to the parameter in the method are reflected in the variable that was passed by reference when control passes back to the calling method.



A variable passed to the method.

JScript can call methods with reference and out parameters, but it cannot define them.

The following example illustrates a use of the Reference (&) operator.

// Define Compute method in C# code.
public class C 
    public static void Compute(ref int sum, out int product, int a, int b) 
        sum = a + b;
        product = a * b;

// Call Compute method from your JScript code.
var a : int, b: int;
C.Compute(&a, &b, 2, 3)