title: Access to modified closure... but why?
body: <p>Saw several similar questions here, but none of them seemed to quite be my issue...</p>
  
  <p>I understand (or thought I understood) the concept of closure, and understand what would cause Resharper to complain about access to a modified closure, but in the below code I don't understand how I'm breaching closure.   </p>
  
  <p>Because <code>primaryApps</code> is declared within the context of the for loop, <code>primary</code> isn't going to change while I'm processing <code>primaryApps</code>.  If I had declared <code>primaryApps</code> outside the for loop, then absolutely, I have closure issues.  But why in the code below?</p>
  
  <pre><code>var primaries = (from row in openRequestsDataSet.AppPrimaries
                   select row.User).Distinct();
  
      foreach (string primary in primaries) {
  
          // Complains because 'primary' is accessing a modified closure
          var primaryApps = openRequestsDataSet.AppPrimaries.Select(x =&gt; x.User == primary);
  </code></pre>
  
  <p>Is Resharper just not smart enough to figure out it's not an issue, or is there a reason closure is an issue here that I'm not seeing?</p>