X hits on this document

1247 views

0 shares

0 downloads

0 comments

143 / 396

C# LANGUAGE SPECIFICATION

The saved value of x becomes the result of the operation.

If x is classified as a property or indexer access:

The instance expression (if x is not static) and the argument list (if x is an indexer access) associated with x are evaluated, and the results are used in the subsequent get and set accessor invocations.

The get accessor of x is invoked and the returned value is saved.

The selected operator is invoked with the saved value of x as its argument.

The set accessor of x is invoked with the value returned by the operator as its value argument.

The saved value of x becomes the result of the operation.

The ++ and -- operators also support prefix notation (§‎7.6.5). The result of x++ or x-- is the value of x before the operation, whereas the result of ++x or --x is the value of x after the operation. In either case, x itself has the same value after the operation.

An operator ++ or operator -- implementation can be invoked using either postfix or prefix notation. It is not possible to have separate operator implementations for the two notations.

7.5.10 The new operator

The new operator is used to create new instances of types.

There are three forms of new expressions:

Object creation expressions are used to create new instances of class types and value types.

Array creation expressions are used to create new instances of array types.

Delegate creation expressions are used to create new instances of delegate types.

The new operator implies creation of an instance of a type, but does not necessarily imply dynamic allocation of memory. In particular, instances of value types require no additional memory beyond the variables in which they reside, and no dynamic allocations occur when new is used to create instances of value types.

7.5.10.1 Object creation expressions

An object-creation-expression is used to create a new instance of a class-type or a value-type.

object-creation-expression: new   type   (   argument-listopt   )

The type of an object-creation-expression must be a class-type or a value-type. The type cannot be an abstract class-type.

The optional argument-list (§‎7.4.1) is permitted only if the type is a class-type or a struct-type.

The compile-time processing of an object-creation-expression of the form new T(A), where T is a class-type or a value-type and A is an optional argument-list, consists of the following steps:

If T is a value-type and A is not present:

The object-creation-expression is a default constructor invocation. The result of the object-creation-expression is a value of type T, namely the default value for T as defined in §‎4.1.1.

Otherwise, if T is a class-type or a struct-type:

If T is an abstract class-type, a compile-time error occurs.

The instance constructor to invoke is determined using the overload resolution rules of §‎7.4.2. The set of candidate instance constructors consists of all accessible instance constructors declared in T which are

130Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views1247
Page views1247
Page last viewedFri Jan 20 04:14:31 UTC 2017
Pages396
Paragraphs9401
Words133190

Comments