Jon Jagger
jon@jaggersoft.com
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 Specificationpreviousnextprevious at this levelnext at this level 15 Statementsprevious at this levelnext at this level 15.9 Jump statements Paragraph 11 Jump statements unconditionally transfer control. jump-statement : break-statement continue-statement goto-statement return-statement throw-statement Paragraph 21 The location to which a jump statement transfers control is called the target of the jump statement. Paragraph 31 When a jump statement occurs within a block, and the target of that jump statement is outside that block, the jump statement is said to exit the block. 2 While a jump statement may transfer control out of a block, it can never transfer control into a block. Paragraph 41 Execution of jump statements is complicated by the presence of intervening try statements. 2 In the absence of such try statements, a jump statement unconditionally transfers control from the jump statement to its target. 3 In the presence of such intervening try statements, execution is more complex. 4 If the jump statement exits 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 intervening try statements have been executed. [Example: In the example
using System;  
class Test  
{  
   static void Main() {  
      while (true) {  
         try {  
            try {  
               Console.WriteLine("Before break");  
               break;  
            }  
            finally {  
               Console.WriteLine("Innermost finally block");  
            }  
         }  
         finally {  
            Console.WriteLine("Outermost finally block");  
         }  
      }  
      Console.WriteLine("After break");  
   }  
}  
the finally blocks associated with two try statements are executed before control is transferred to the target of the jump statement.
The output produced is as follows:
Before break  
Innermost finally block  
Outermost finally block  
After break  
end example]
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS