Function members are members that contain executable code. The language determines the following categories of function members:
Except for static constructors, statements contained in function members are executed as a result of member invocations. The actual syntax of a function member invocation depends on the member category. The argument list of a function member invocation provides actual values or variable references corresponding to the parameters of the function member.
Invocations of methods, indexers, and instance constructors employ overload resolution to determine, which of a candidate set of function members to invoke. This process is described in §7.4.2
§7.4.2.1 describes the actual runtime process of invoking the function member.
Each function member invocation contains an argument list that determines actual values or variable references corresponding to function member parameters. The syntax for specifying an argument list depends on the function member category:
For instance constructors, methods and delegates, arguments are specified as an argument list as described below.
For simple properties, the argument list is empty when invoking the property value reading method, and consists of the expression specified as the right operand part of the assignment statement when invoking the property value setting method.
For indexers, the argument list consists of the expressions specified between the square brackets in the indexer access. When invoking the property value setting method, the argument list additionally includes the expression specified as the right operand part of the assignment statement.
The arguments of simple properties and events are always passed as value parameters. Indexer arguments are also passed as value parameters or as array parameters. Reference and output parameters are not supported for these categories of function members. Parameter types and their differences are described in the Methods: Method Parameters section.
Arguments of constructors, methods, or delegates are specified as an argument list:
argument-list:
( argumentsopt )
arguments:
argument
arguments , argument
argument:
expression
Var variable-reference
Out variable-reference
variable-reference:
expression
An argument list consists of one or more arguments separated by commas. Each argument can take one of the following forms:
An expression indicating that the argument is passed as a value parameter.
The Var keyword followed by a variable reference indicating that the argument is passed as a reference parameter.
The Out keyword followed by a variable reference indicating that the argument is passed as an output parameter.
During the runtime processing of a function member invocation, the expressions or variable references of an argument list are calculated in order, from left to right, as follows:
For a value parameter, the specified expression is calculated and an implicit conversion is used to convert the calculated value to the corresponding parameter type. The output value becomes the initial value of the value parameter in the function member invocation.
For reference and output parameters, the variable reference is calculated and the output memory cell pointer becomes the value represented by the corresponding variable.
Methods, indexers and instance constructors may have a variable number of parameters. Such function members are invoked either in their normal form or in their expanded form depending on which is applicable:
When a function member is invoked in its normal form, the argument given for the parameter array must be a single expression of a type that is implicitly convertible to the parameter array type. In this case, this parameter acts precisely like a standard parameter passed by a value.
When a function member is invoked in its expanded form, the invocation must specify zero or more arguments, where each argument is implicitly convertible to the element type of the parameter array. In this case, the invocation creates an instance of the parameter array type with a length corresponding to the number of arguments, and array elements are initialized with the given argument values. The created array instance is used as a parameter value.
See also: