title: PropertyInfo.GetValue(object) fails with IEnumerable<T> [C#, Reflection]
body: <p>I have the following problem:<br>
  I am currently writing the c# equivalent of PHP's <code>var_dump</code>-method. It works perfectly with 'simple' classes and structures (and even with arrays).<br>
  My only problem is when it comes to other <code>IEnumerable&lt;T&gt;</code>, like <code>List&lt;T&gt;</code> etc:</p>
  
  <p>The debugger is throwing an <code>TargetParameterCountException</code>. My code looks as follows:</p>
  
  <pre><code>Type t = obj.GetType(); // 'obj' is my variable, i want to 'dump'
  string s = "";
  PropertyInfo[] properties = t.GetProperties();
  
  for (int i = 0; i &lt; properties.Length; i++)
  {
      PropertyInfo property = properties[i];
  
      object value = property.GetValue(obj); // &lt;-- throws exception
  
      if (value is ICollection)
      {
          // Code for array parsing - is irrelevant for this problem
      }
      else
          s += "Element at " + i + ": " + value.GetType().FullName + " " + value.ToString() + "\n";
  }
  
  return s;
  </code></pre>
  
  <p>I know, that i can somehow fetch indices with <code>PropertyInfo.GetIndexParameters()</code>, but I did not figured out, how to use it correctly.</p>
  
  <p><strong>Edit:</strong> I also want to note that I neither know the size of the IEnumerable, nor the Type T at compile time.</p>