title: Providing the Type to instanciate a generic Class
body: <p>I got the following code to create my class :</p>
  
  <pre><code>public class GenericObject&lt;T&gt;
  {
      [...]
  
      public GenericObject(object source, string propertyName)
      {
          [...]
      }
  }
  </code></pre>
  
  <p>and then I'd like to create instances of my Class. here is the loop I have :</p>
  
  <pre><code>        foreach (PropertyInfo pi in container.GetType().GetProperties())
          {
                  //var type = pi.PropertyType;
                  GenericObject&lt;pi.PropertyType&gt; p = new GenericObject&lt;pi.PropertyType&gt;(container, pi.Name);
          }
  </code></pre>
  
  <p>The compiler tells me that 'pi' is not a namespace (???)
  I tried with this code :</p>
  
  <pre><code>Type type = pi.PropertyType;
  GenericObject&lt;type&gt; p = new GenericObject&lt;type&gt;(container, pi.Name);
  </code></pre>
  
  <p>but I got the same error ('type' not a namespace)
  What have I to do ? thx in advance for any help</p>