title: LINQ + Foreach vs Foreach + If
body: <p>I need to iterate over a List of objects, doing something only for the objects that have a boolean property set to true.  I'm debating between this code</p>
  
  <pre><code>foreach (RouteParameter parameter in parameters.Where(p =&gt; p.Condition))
  { //do something }
  </code></pre>
  
  <p>and this code</p>
  
  <pre><code>foreach (RouteParameter parameter in parameters)
  { 
    if !parameter.Condition
      continue;
    //do something
  }
  </code></pre>
  
  <p>The first code is obviously cleaner, but I suspect it's going to loop over the list twice - once for the query and once for the foreach.  This won't be a huge list so I'm not overly concerned about performance, but the idea of looping twice just <em>bugs</em> me.</p>
  
  <p>Question: Is there a clean/pretty way to write this without looping twice?</p>