title: Declaring and using a array of anonymous objects in C#
body: <p>How many times we declare a simple class or struct to hold a few properties only to use them only one time when returned by a method. Way too many times I think, thankfully we always have anonymous objects which can be declared in place at run time.</p>
  
  <p>With that thought in mind I would like to know how I can declare one array of such anonymous objects.</p>
  
  <p>Example: </p>
  
  <pre><code>var Employee = new { ID = 5, Name= "Prashant" };
  </code></pre>
  
  <p>This created a anonymous object with two properties, one being integer and another string.</p>
  
  <p>All good here, but how should I declare a array of this kind of object, and how would you recommend iterating through it with both a <code>for</code> and <code>foreach</code> loops.</p>
  
  <p>The <code>foreach</code> loop is really the problem I think, because foreach loops expect a declared type. Still there might be a away, if there is I would to know it too of course.</p>