title: Cast IEnumerable to IEnumerable<T> when T is unknown at compile time
body: <p>I have a sorting extension method with the following signature:</p>
  
  <pre><code>public static IEnumerable&lt;T&gt; CustomSort&lt;T&gt;(this IEnumerable&lt;T&gt; source, string sortProperties)
  </code></pre>
  
  <p>We wrote it a while back and it has been doing its thing. Now I am creating a custom control and the DataSource property is an IEnumerable (non-generic).
  Is there any way to get the type of the objects in a non-generic IEnumerable?</p>
  
  <p>I am sure the problem of "sort a custom control data source" has been solved a million times, but I just can't seem to find a solution.</p>