title: Using Linq to run a method on a collection of objects?
body: <p>This is a long shot, I know...</p>
  
  <p>Let's say I have a collection</p>
  
  <pre><code>List&lt;MyClass&gt; objects;
  </code></pre>
  
  <p>and I want to run the same method on every object in the collection, with or without a return value.  Before Linq I would have said:</p>
  
  <pre><code>List&lt;ReturnType&gt; results = new List&lt;ReturnType&gt;();
  List&lt;int&gt; FormulaResults = new List&lt;int&gt;();
  foreach (MyClass obj in objects) {
    results.Add(obj.MyMethod());
    FormulaResults.Add(ApplyFormula(obj));
  }
  </code></pre>
  
  <p>I would <strong>love</strong> to be able to do something like this:</p>
  
  <pre><code>List&lt;ReturnType&gt; results = new List&lt;ReturnType&gt;();
  results.AddRange(objects.Execute(obj =&gt; obj.MyMethod())); 
  // obviously .Execute() above is fictitious
  List&lt;int&gt; FormulaResults = new List&lt;int&gt;();
  FormulaResults.AddRange(objects.Execute(obj =&gt; ApplyFormula(obj)));
  </code></pre>
  
  <p>I haven't found anything that will do this.  Is there such a thing?</p>
  
  <p>If there's nothing generic like I've posited above, at least maybe there's a way of doing it for the purposes I'm working on now: I have a collection of one object that has a wrapper class:</p>
  
  <pre><code>class WrapperClass {
    private WrappedClass wrapped;
    public WrapperClass(WrappedClass wc) {
      this.wrapped = wc;
    }
  }
  </code></pre>
  
  <p>My code has a collection <code>List&lt;WrappedClass&gt; objects</code> and I want to convert that to a <code>List&lt;WrapperClass&gt;</code>.  Is there some clever Linq way of doing this, without doing the tedious</p>
  
  <pre><code>List&lt;WrapperClass&gt; result = new List&lt;WrapperClass&gt;();
  foreach (WrappedClass obj in objects)
    results.Add(new WrapperClass(obj));
  </code></pre>
  
  <p>Thanks...</p>