title: How do I iterate over the properties of an anonymous object in C#?
body: <p>I want to take an anonymous object as argument to a method, and then iterate over its properties to add each property/value to a a dynamic <code>ExpandoObject</code>.  </p>
  
  <p>So what I need is to go from </p>
  
  <pre><code>new { Prop1 = "first value", Prop2 = SomeObjectInstance, Prop3 = 1234 }
  </code></pre>
  
  <p>to knowing names and values of each property, and being able to add them to the <code>ExpandoObject</code>.</p>
  
  <p>How do I accomplish this?</p>
  
  <p>Side note: This will be done in many of my unit tests (I'm using it to refactor away a lot of junk in the setup), so performance is to some extent relevant. I don't know enough about reflection to say for sure, but from what I've understood it's pretty performance heavy, so if it's possible I'd rather avoid it...</p>
  
  <p><strong>Follow-up question:</strong>
  As I said, I'm taking this anonymous object as an argument to a method. What datatype should I use in the method's signature? Will all properties be available if I use <code>object</code>?</p>