13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C#</strong> LANGUAGE SPECIFICATION14.4 Function membersFunction members are members that contain executable statements. Function members are always membersof types and cannot be members of namespaces. <strong>C#</strong> defines the following categories of function members:• Methods• Properties• Events• Indexers• User-defined operators• Instance constructors• Static constructors• DestructorsExcept for static constructors and destructors (which cannot be invoked explicitly), the statements containedin function members are executed through function member invocations. The actual syntax for writing afunction member invocation depends on the particular function member category.The argument list (§14.4.1) of a function member invocation provides actual values or variable referencesfor the parameters of the function member.Invocations of methods, indexers, operators, and instance constructors employ overload resolution todetermine which of a candidate set of function members to invoke. This process is described in §14.4.2.Once a particular function member has been identified at compile-time, possibly through overloadresolution, the actual run-time process of invoking the function member is described in §14.4.3.[Note: The following table summarizes the processing that takes place in constructs involving the sixcategories of function members that can be explicitly invoked. In the table, e, x, y, and value indicateexpressions classified as variables or values, T indicates an expression classified as a type, F is the simplename of a method, and P is the simple name of a property.Construct Example DescriptionMethodinvocationF(x, y)Overload resolution is applied to select the best method F in thecontaining class or struct. The method is invoked with theargument list (x, y). If the method is not static, theinstance expression is this.PropertyaccessT.F(x, y)e.F(x, y)PP = valueOverload resolution is applied to select the best method F in theclass or struct T. A compile-time error occurs if the method isnot static. The method is invoked with the argument list(x, y).Overload resolution is applied to select the best method F in theclass, struct, or interface given by the type of e. A compile-timeerror occurs if the method is static. The method is invokedwith the instance expression e and the argument list (x, y).The get accessor of the property P in the containing class orstruct is invoked. A compile-time error occurs if P is writeonly.If P is not static, the instance expression is this.The set accessor of the property P in the containing class orstruct is invoked with the argument list (value). A compiletimeerror occurs if P is read-only. If P is not static, theinstance expression is this.130

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!