Continue in nested while loops

后端 未结 10 1551
名媛妹妹
名媛妹妹 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:22

    Swap the try/catch structure with the inner while loop:

    while {
      try {
        while {
          throw;
        }
      }
      catch {
        continue;
      }
    }
    

提交回复
热议问题