title: C# boolean compare vs set performance
body: <p>In C#, suppose I have a <code>foreach</code> loop and it is possible that the iterator will be empty. Following the loop, more actions need to be taken only if the iterator was not empty. So I declare <code>bool res = false;</code> before the loop. Is it faster to just set <code>res = true;</code> in each loop iteration, or to test if it's been done yet, as in <code>if (!res) res = true;</code>. I suppose the question could more succinctly be stated as "is it faster to set a <code>bool</code>'s value or test its value?"</p>
  
  <p>In addition, even if one is slightly faster than the other, is it feasible to have so many iterations in the loop that the impact on performance is not negligible?</p>