title: LINQ list property to array?
body: <p>What's the best way to do this where <code>PROPNAME</code> could be any property of type <code>T</code>?  Build it up with reflection, or is there a good LINQ way of doing this?</p>
  
  <pre><code>T[] vals = people.Select(x =&gt; x.PROPNAME).ToArray&lt;T&gt;();
  </code></pre>
  
  <p>this is the best I've got so far:</p>
  
  <pre><code>    public T[] ConvertListCol&lt;TFrom,T&gt;(IEnumerable&lt;TFrom&gt; list, string col)
      {
          var typ = typeof (TFrom);
          var props = typ.GetProperties();
          var prop = (from p in props where p.Name == col select p).FirstOrDefault();
          var ret = from o in list select prop.GetValue(o, null);
          return ret.ToArray&lt;T&gt;();
      }
  </code></pre>
  
  <p>Got an error in the return... but getting closer.  It's okay, but a little messier than I'd hoped.</p>