title: IEnumerable<T> and reflection
body: <p><strong>Background</strong></p>
  
  <p>Working in .NET 2.0 Here, reflecting lists in general. I was originally using <code>t.IsAssignableFrom(typeof(IEnumerable))</code> to detect if a Property I was traversing supported the <code>IEnumerable</code> Interface. (And thus I could cast the object to it safely)</p>
  
  <p>However this code was not evaluating to <code>True</code> when the object is a <code>BindingList&lt;T&gt;</code>.</p>
  
  <p><strong>Next</strong></p>
  
  <p>I tried to use <code>t.IsSubclassOf(typeof(IEnumerable))</code> and didn't have any luck either.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>    /// &lt;summary&gt;
      /// Reflects an enumerable (not a list, bad name should be fixed later maybe?)
      /// &lt;/summary&gt;
      /// &lt;param name="o"&gt;The Object the property resides on.&lt;/param&gt;
      /// &lt;param name="p"&gt;The Property We're reflecting on&lt;/param&gt;
      /// &lt;param name="rla"&gt;The Attribute tagged to this property&lt;/param&gt;
      public void ReflectList(object o, PropertyInfo p, ReflectedListAttribute rla)
      {
          Type t = p.PropertyType;
          //if (t.IsAssignableFrom(typeof(IEnumerable)))
          if (t.IsSubclassOf(typeof(IEnumerable)))
          {
              IEnumerable e = p.GetValue(o, null) as IEnumerable;
  
              int count = 0;
              if (e != null)
              {
                  foreach (object lo in e)
                  {
                      if (count &gt;= rla.MaxRows)
                          break;
  
                      ReflectObject(lo, count);
  
                      count++;
                  }
              }
          }
      }
  </code></pre>
  
  <p><strong>The Intent</strong></p>
  
  <p>I want to basically tag lists i want to reflect through with the <code>ReflectedListAttribute</code> and call this function on the properties that has it. (Already Working)</p>
  
  <p>Once inside this function, given the object the property resides on, and the <code>PropertyInfo</code> related, get the value of the property, cast it to an IEnumerable (assuming it's possible) and then iterate through each child and call <code>ReflectObject(...)</code> on the child with the count variable.</p>