title: Create Generic List<Type> from PropertyInfo
body: <p>In one of my classes I have the following property:</p>
  
  <pre><code>public List&lt;ClassP&gt; MyPlanes { get; set; }
  </code></pre>
  
  <p>In another method I have a the <code>propertyInfo</code> of the property above (the function self does not know where the propertyinfo comes from). Right now i'm trying to <code>create a list of classP</code> when i only have the propertyInfo of <code>MyPlanes</code>. So far my attempts seem to be in vain, this is howfar i got sofar:</p>
  
  <p><em>variable prop is the PropertyInfo of MyPlanes</em></p>
  
  <pre><code>public void GenerateList(PropertyInfo prop)
  {
              if (prop.PropertyType.IsGenericType &amp;&amp; prop.PropertyType.GetGenericArguments().Length &gt; 0)
              { 
                  List&lt;prop.PropertyType.GetGenericArguments().First()&gt; myValueList = 
                      new List&lt;prop.PropertyType.GetGenericArguments().First()&gt;();
              }
  }
  </code></pre>
  
  <p>The creating of the list (with the code above) gives the following error <code>Using the generic type 'System.Collections.Generic.List&lt;T&gt;' requires 1 type arguments</code></p>
  
  <p>Any help would be greatly appreciated</p>
  
  <p><strong>Note:</strong> I want the list creating in a syntax (or a syntax similar) as visible above. I want to keep my code as generic as possible</p>