title: How to break out of nested for loops
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop">Breaking out of a nested loop</a><br>
    <a href="https://stackoverflow.com/questions/982595/how-to-break-out-of-2-loops-without-a-flag-variable-in-c">How to break out of 2 loops without a flag variable in C#?</a>  </p>
  </blockquote>
  
  
  
  <p>Hello I have a function that has nested loops. Once the condition has been met, I want to break out of nested loops. The code is something like this below:</p>
  
  <pre><code>foreach (EmpowerTaxView taxView in taxViews)
              {
                  foreach (PayrollEmployee payrollEmployee in payrollEmployees)
                  {
                      //PayStub payStub = payrollEmployee.InternalPayStub;
  
                      IReadOnlyList&lt;PayrollWorkLocation&gt; payrollWorkLocations =  payrollEmployee.PayrollWorkLocations;
  
                      foreach (PayrollWorkLocation payrollWorkLocation in payrollWorkLocations)
                      {
                          Tax tax = GetTaxEntity(payrollWorkLocation, taxView.BSITypeCode, taxView.BSIAuthorityCode,
                                                 paidbyEr, resCode);
  
                          if (tax != null &amp;&amp; tax.Rate.HasValue)
                          {
                              taxRate = tax.Rate.Value;
                              break;
                          }
                      }
                  }
              }
  </code></pre>
  
  <p>Unfortunately, break comes out of only one loop. I want to break out of the whole thing. Please, I know some people have suggested goto: statement. I am wondering is there any other way around, such writing some LINQ queries to the same effect.</p>
  
  <p>Any ideas and suggestions are greatly appreciated !</p>