title: Best Practice: Nested ForEach
body: <p>Is there a best practice for the number of nested "foreach"? </p>
  
  <p>That is I'm spiraling into nested "foreach" over Complex dictionaries, is there a point where it starts to produce overhead that "COULD" impede performance? Is this something even worth considering.</p>
  
  <p>To make it specific and not open to being subjective:
  I have 3 Complex Dictionaries that look like this;</p>
  
  <pre><code>Dictionary&lt;int, Dictionary&lt;string, XObject&gt;()
  Dictionary&lt;string, List&lt;YObject&gt;()
  Dictionary&lt;string, Dictionary&lt;string, List&lt;ZObjects&gt;()
  </code></pre>
  
  <p>Obviously now, as I filter these Dictionary (in a foreach), to produce the data I'm looking for, the structure of my code is heading towards 5 Nested "foreach" excluding the Outer 1. In answering these are the areas I'm worried might be impacted:</p>
  
  <ol>
  <li><strong>Performance</strong> (too many context switches)   </li>
  <li><strong>Memory</strong> (retaining all the datasets in memory at a given instant) </li>
  <li><strong>Maintainability</strong> (bad programmer!)</li>
  </ol>
  
  <p>Best practice or doesn't matter?</p>