This documentation is archived and is not being maintained.

11.8 Invocation Expressions

Visual Studio .NET 2003

An invocation expression consists of an invocation target, followed by an opening parenthesis, an optional argument list, and a closing parenthesis. The target expression must be classified as a method group or a value whose type is a delegate type. If the target expression is a value, then the target of the invocation expression becomes the method group referring to the Invoke member of the delegate type.

An argument list has two sections: positional arguments and named arguments. Positional arguments are expressions and must precede any named arguments. Named arguments start with an identifier that can match keywords, followed by := and an expression.

Given a method group, overload resolution is applied to pick a single method applicable to the given argument list. If the method group only contains one method and that method takes no arguments and is a function, then the method group is interpreted as an invocation expression with an empty argument list and the result is used as the target of an index expression. If no method is applicable, a compile-time error occurs. If the applicable method is a function, then the result of the invocation expression is classified as a value typed as the return type of the function. If the applicable method is a subroutine, then the result is classified as void.

InvocationExpression ::= Expression [ ( [ ArgumentList ] ) ]
ArgumentList ::=
   PositionalArgumentList , NamedArgumentList |
   PositionalArgumentList |
PositionalArgumentList ::=
   Expression |
   PositionalArgumentList , [ Expression ]
NamedArgumentList ::=
   IdentifierOrKeyword : = Expression |
   NamedArgumentList , IdentifierOrKeyword : = Expression

See Also

11.8.4 Conditional Methods | 11.8.2 Applicable Methods | 11.8.1 Overloaded Method Resolution | 11.4 Simple Expressions | 11.6 Member Access Expressions | 11.9 Index Expressions | 11.10 New Expressions | 11.11 Cast Expressions | 11.12 Operator Expressions | 11.3 Late-Binding Expressions | 11.4.5 AddressOf Expressions | 6.2.3 Option Compare Statement | 11.8 Invocation Expressions | Reference Parameters | Expressions (Visual Basic Language Concepts) | Argument Passing by Position and Name (Visual Basic Language Concepts)