title: Working with C# Anonymous Types
body: <p>I am calling a method that returns a List variable that contains a c# Anonymous Type objects. For example:</p>
  
  <pre><code>List&lt;object&gt; list = new List&lt;object&gt;();
  foreach ( Contact c in allContacts ) {
      list.Add( new {
          ContactID = c.ContactID,
          FullName = c.FullName
      });
  }
  return list;
  </code></pre>
  
  <p>How do I reference this type properties in the code I am working on like for example</p>
  
  <pre><code>foreach ( object o in list ) {
      Console.WriteLine( o.ContactID );
  }
  </code></pre>
  
  <p>I know that my sample is not possible, I have only wrote that way to say that I need to identify each property of the anonymous type exactly.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Solution</strong>:</p>
  
  <p>Not just one of the answer is correct and/or suggest a working solution. I have ended up to using Option 3 of Greg answer. And I learned something very interesting regarding the <code>dynamic</code> in .NET 4.0!</p>