title: C# Extract list of fields from list of class
body: <p>I've got a list of elements of a certain class. This class contains a field.</p>
  
  <pre><code>class Foo {public int i;}
  List&lt;Foo&gt; list;
  </code></pre>
  
  <p>I'd like to extract the field from all items in the list into a new list.</p>
  
  <pre><code>List&lt;int&gt; result = list.ExtractField (e =&gt; e.i); // imaginary
  </code></pre>
  
  <p>There are surely multiple ways to do that, but I did not find a nice-looking solution yet. I figured linq might help, but I was not sure how exactly.</p>