An expression is a sequence of operators and operands. This section determines the syntax, order of evaluation of operands and operators, and meaning of expressions.
An expression is classified as one of the following:
Value. Every value has an associated type.
Variable. Every variable has an associated type, namely the declared type of the variable.
Namespace. An expression with this classification can only appear as the left hand side of a member access. In any other context, an expression classified like this causes a compile-time error.
Type. An expression with this classification can only appear as the left hand side of a member access, or as an operand in Is and As operators. In any other context, an expression classified like this causes a compile-time error.
A method group, which is a set of overloaded methods resulting from a member lookup. A method group may have an associated instance expression. When an instance method is invoked, the result of evaluating the instance expression becomes the instance represented by Self. A method group is only permitted in an invocation operation, or delegate creation expression, where it can also be implicitly converted to a compatible delegate type. In any other context, an expression classified as a method group causes a compile-time error.
Property Access. Every expression classified as a property access has an associated type, namely the type of the property. Furthermore, a property access may have an associated argument list and instance expression. When a method of an instance property access is invoked, the result of evaluating the instance expression becomes the instance represented by Self, and calculated values of the argument list (if there are any) form invocation parameters.
Event Access. Every expression classified as an event access has an associated type, namely the type of the event (delegate). Furthermore, an event access may have an associated instance expression. An expression classified like this may appear only in the left part of an assignment statement. In any other context, an expression classified like this causes a compile-time error.
Empty. This occurs when the expression is an invocation of a method that has no returned value. An expression classified like this may only be used in a context of a invocation statement.
The final result of an expression is never a namespace, type, method group, or event access. These expression categories are intermediate structures that are only permitted in certain contexts.
A property access is always reclassified as a value by executing an accessor invocation. The required accessor is determined by the context, in which the property is used. If it is used in the context of an assignment statement, the method for setting the property value is invoked. Otherwise, the accessor to get the property value is invoked.
Additional information is contained in the following subsections: