title: How can I access an use the objects in my List<dynamic> when they are each passed into an Action<T>?
body: <p>Apologies if this is a duplicate but I can't find it.</p>
  
  <p>Here is the essence of my problem.  Let's assume I have a <code>List&lt;T&gt;</code> containing dynamic objects:</p>
  
  <pre><code>var collection = new List&lt;dynamic&gt; 
  {
      new { Foo = 1, Bar = "Test Text..."},
      new { Foo = 2, Bar = "Test Text #2..."},
      new { Foo = 3, Bar = "Test Text #3..."},
  };
  </code></pre>
  
  <p>Now, imagine we want to iterate over this collection, and pass each <code>dynamic</code> to an <code>Action&lt;T&gt;</code>.  Specifically in my case, I need to pass my objects into a <code>Parallel.Foreach</code> call.  I've been able to construct the following code and the application can properly build.</p>
  
  <pre><code>Parallel.ForEach(collection, (s) =&gt; 
      { 
          Console.WriteLine("Success!");
      });
  </code></pre>
  
  <p>Of course, this is essentially useless until we operate on the parameter.  What I need to do is access the <code>s</code> parameter within the lambda.  </p>
  
  <p>Something like this:</p>
  
  <pre><code>Parallel.ForEach(collection, (s) =&gt; 
      { 
          Console.WriteLine("Foo = {0}, Bar = {1}", s.Foo, s.Bar);
      });
  </code></pre>
  
  <p>However, when I try to write such code I get a VS error stating:</p>
  
  <blockquote>
    <p>One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?</p>
  </blockquote>
  
  <p>How can I access my dynamic object from within my lambda expression?</p>