Continue in nested while loops

后端 未结 10 1560
名媛妹妹
名媛妹妹 2020-12-07 14:26

In this code sample, is there any way to continue on the outer loop from the catch block?

while
{
   // outer loop

   while
   {
       // inner loop
               


        
10条回答
  •  情歌与酒
    2020-12-07 15:13

    No.
    I suggest, extracting the inner loop into a separate method.

    while
    {
       // outer loop
           try
           {
               myMethodWithWhileLoopThatThrowsException()
           }
           catch 
           {
               // how do I continue on the outer loop from here?
               continue;
           }
       }
    }
    

提交回复
热议问题