Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specification 15 Statements 15.9 Jump statements 15.9.4 The return statement
Paragraph 11 The return statement returns control to the caller of the function member in which the return statement appears. return-statement : return expressionopt ;
Paragraph 21 A return statement with no expression can be used only in a function member that does not compute a value; that is, a method with the return type void, the set accessor of a property or indexer, the add and remove accessors of an event, an instance constructor, static constructor, or a destructor.
Paragraph 31 A return statement with an expression can only be used in a function member that computes a value, that is, a method with a non-void return type, the get accessor of a property or indexer, or a user-defined operator. 2 An implicit conversion (§13.1) must exist from the type of the expression to the return type of the containing function member.
Paragraph 41 It is a compile-time error for a return statement to appear in a finally block (§15.10).
Paragraph 51 A return statement is executed as follows:
Paragraph 61 Because a return statement unconditionally transfers control elsewhere, the end point of a return statement is never reachable.
- 2 If the return statement specifies an expression, the expression is evaluated and the resulting value is converted to the return type of the containing function member by an implicit conversion. 3 The result of the conversion becomes the value returned to the caller.
- 4 If the return statement is enclosed by one or more try blocks with associated finally blocks, control is initially transferred to the finally block of the innermost try statement. 5 When and if control reaches the end point of a finally block, control is transferred to the finally block of the next enclosing try statement. 6 This process is repeated until the finally blocks of all enclosing try statements have been executed.
- 7 Control is returned to the caller of the containing function member.
|Jagger Software Ltd|
|Company # 4070126|
|VAT # 762 5213 42|