Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error CS1632
Collapse the table of content
Expand the table of content

Compiler Error CS1632 

Error Message

Control cannot leave the body of an anonymous method

This error occurs if a jump statement (break, goto, continue, etc.) attempts to move control out of an anonymous method block. An anonymous method block is a function body and can only be exited by a return statement or by reaching the end of the block.

The following sample generates CS1632:

// CS1632.cs
// compile with: /target:library
delegate void MyDelegate();
class MyClass
   public void Test()
      for (int i = 0 ; i < 5 ; i++)
         MyDelegate d = delegate {
            break;   // CS1632

Community Additions

© 2015 Microsoft