title: Get contained type in a List<T> through reflection?
body: <p>Through reflection, is there some way for me to look at a generic List's contained type to see what type the collection is of?  For example:</p>
  
  <p>I have a simple set of business objects that derive from an interface, like this:</p>
  
  <pre><code>public interface IEntityBase{}  
  
  public class BusinessEntity : IEntityBase   
  {
      public IList&lt;string&gt; SomeStrings {get; set;}       
      public IList&lt;ChildBusinessEntity&gt; ChildEntities { get; set;}
  } 
  
  public class ChildBusinessEntity : IEntityBase{}
  </code></pre>
  
  <p>In the case where I am iterating through the properties of BusinessEntity through reflection, would there be a way for me to see if the objects nested inside those lists derived from IEntityBase?</p>
  
  <p><strong>Pseudo</strong>coded (badly) like this:</p>
  
  <pre><code>foreach(PropertyInfo info in typeof(BusinessEntity).GetProperties())
  {
    if(info.PropertyType is GenericIList &amp;&amp;
       TheNestedTypeInThisList.IsAssignableFrom(IEntityBase)
    {
      return true;
    }
  }
  </code></pre>
  
  <p>Only option I've heard so far, that works, would be to pull out the first item from that list, then look at its type.  Any easier way (especially because I can't be guaranteed that the List won't be empty)?</p>