Expression is a sequence of operators and operands. This section determines expression syntax, order of evaluation of operators and operands, and meaning of expressions.
An expression can be 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 at the left part of a member access. In any other context, an expression classified like this causes a compilation error.
Type. An expression with this classification can only appear at the left part of a member access, or as an operand in the Is and As operators. In any other context, an expression classified like this causes a compilation 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 operator, or delegate creation operator 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 compilation error.
Property access. Every expression classified as a property access has an associated type, namely the property type. Furthermore, a property access may have an associated argument list and instance expression. When a property access method is invoked, the result of calculating the instance expression becomes the instance represented by Self, and calculated values of the arguments list (if there are any) form invocation parameters.
Event access. Every expression classified as an event access has an associated type, namely the event type (delegate). Furthermore, an event access may have an associated instance expression. An expression classified like this may appear only at the left part of an assignment statement. In any other context, an expression classified like this causes a compilation error.
Empty. This occurs when the expression is an invocation of a method that has no returned value. Expressions 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 access method invocation. The required access method 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 access method to get the property value is invoked.
Additional information is contained in the following subsections: